Wednesday, March 8, 2017

Two different ways to find file extension in PHP

Two different ways to find file extension in PHP



You can find a file extension in PHP using different ways.

Today Ill show you two different ways.

The first is a built-in PHP function called pathinfo(), which is used as follows:
$ext = pathinfo($filepath, PATHINFO_EXTENSION);
 Or by using some geeky PHP code as follows:
$path = /path/to/img.gif;
$path
= explode(.,$path);
$path
= end($path);
Thats It!
Sometimes, the key is in simplicity 

Go to link download