Skip to content

Instantly share code, notes, and snippets.

@flacodirt
Created May 31, 2013 13:06
Show Gist options
  • Save flacodirt/5684854 to your computer and use it in GitHub Desktop.
Save flacodirt/5684854 to your computer and use it in GitHub Desktop.
Separate name and extension of given file
// Separate name and extension of given file
$fullFileName = 'my.example.file.ext';
$fileExt = substr($fullFileName, strrpos($fullFileName, '.') + 1);
$fileName = str_replace("." . $fileExt, "", $fullFileName);
/**
* Results:
*
* $fileExt = ext
* $fileName = my.example.file
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment