EXE or GIF or DLL or …
Most of the code chunks I’ve seen about getting a file extension from
a string are based on some sort of string manipulation.
$filename = '/my/path/image.jpeg';Howerver there is a more elegant solution.
echo substr($filename, strrpos($filename, '.') + 1);
$filename = '/my/path/image.jpeg';Thus you rely on PHP built in functions and it’s harder to overlook the exact string manipulation approach.
echo strtolower(pathinfo($filename, PATHINFO_EXTENSION));