Web development, scripts, source code and IT stuff
Detect file extension in PHP
Super easy trick to find a file extension:
$file="some_file.jpg"; $ext=end(explode(".", $file);
Other ways:
Substring:
$ext = substr($file, strrpos($file, '.') + 1); //or: $ext= substr(strrchr($file, "."), 1 );
Using path info:
$info = pathinfo($file); $ext=$info['extenstion'];