Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Created October 14, 2013 14:26
Show Gist options
  • Save matthewpoer/6976508 to your computer and use it in GitHub Desktop.
Save matthewpoer/6976508 to your computer and use it in GitHub Desktop.
Return the file name from a provided $url. URL should be absolute.
/**
* Return the file name from a provided $url
*
* URL structure should be absolute, e.g.
* http://site.example.com/path/file_name_to_find.ext
*
* @param $url string
* @return string
*/
function grab_filename_from_url($url){
$a = explode('/',$url);
return $a[count($a)-1];
}
@matthewpoer
Copy link
Author

return basename($url) is better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment