Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
php get file extension name
/**
* 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