Skip to content

Instantly share code, notes, and snippets.

@Debashis-Sinha
Created July 16, 2017 07:45
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 Debashis-Sinha/c887f7db2555580cde96bd7c0c81b5d6 to your computer and use it in GitHub Desktop.
Save Debashis-Sinha/c887f7db2555580cde96bd7c0c81b5d6 to your computer and use it in GitHub Desktop.
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