Last active
December 19, 2015 02:48
-
-
Save attitude/5885205 to your computer and use it in GitHub Desktop.
Handy function to return file extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "attitude/Functions/get_file_extension" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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