johnmahugu

php - get last arguments

Jun 14th, 2015
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. /*
  2. Path get last argument
  3.  
  4. This function returns the last argument (filename or directory name) of an given path.
  5. */
  6.  
  7. function path_get_last_arg($path){
  8.     $path = str_replace('\\', '/', $path);
  9.     $path = preg_replace('/\/+$/', '', $path);
  10.     $path = explode('/', $path);
  11.     $l = count($path)-1;
  12.     return isset($path[$l]) ? $path[$l] : '';
  13. }
Advertisement
Add Comment
Please, Sign In to add comment