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'];
- phpSEO - Class for better SEO in PHP
- PHP Class for better cache - fileCache
- PHP sitemap.xml generator
- Add PDF files inside other PDF in PHP
- Print folder contents recursive with indent - PHP
Help sharing and Flatter me ;)
