Skip to content

Instantly share code, notes, and snippets.

@attitude
Last active December 19, 2015 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attitude/5885222 to your computer and use it in GitHub Desktop.
Save attitude/5885222 to your computer and use it in GitHub Desktop.
Handy function to return file name without extension
{
"name": "attitude/Functions/get_file_filename"
}
<?php
/**
* Handy function to return file name without extension
*
* @param string $str Any file name, path or url
* @returns mixed File name without extension (string) or false (bool)
* @author Martin Adamko <@martin_adamko>
* @license The MIT license <http://opensource.org/licenses/MIT>
*
*/
function get_file_filename($str)
{
return substr($str,0, strpos($str, get_file_extension($str))-1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment