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/5885205 to your computer and use it in GitHub Desktop.
Save attitude/5885205 to your computer and use it in GitHub Desktop.
Handy function to return file extension
{
"name": "attitude/Functions/get_file_extension"
}
<?php
/**
* Handy function to return file extension
*
* @param string $str Any file name, path or url
* @returns mixed Extension (string) or false (bool)
* @author Martin Adamko <@martin_adamko>
* @license The MIT License <http://opensource.org/licenses/MIT>
*
*/
function get_file_extension($str)
{
return substr(strrchr($str,'.'),1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment