Created
July 16, 2017 07:45
-
-
Save Debashis-Sinha/c887f7db2555580cde96bd7c0c81b5d6 to your computer and use it in GitHub Desktop.
php get file extension name
This file contains 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
/** | |
* Get file extension | |
* @param $filePath | |
* @return string | |
*/ | |
public function getExtension( $filePath ) | |
{ | |
if( strpos( $filePath, '.' ) === false ){ | |
return ''; | |
} | |
$temp_arr = $filePath ? explode( '.', $filePath ) : array(); | |
$ext = !empty( $temp_arr ) ? end( $temp_arr ) : ''; | |
return strtolower( $ext ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment