This function will grab the file extension from a filename, and put it in it’s own variable.

function findexts ($filename) {
$filename = strtolower($filename) ;
$exts = split(“[/\\.]”, $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;

So for example, if you wanted to get the extension from a file name stored in the variable $filename, you would do this..

$grabext = findexts($filename);

Let me know how it turns out for you or if there are any questions.

No Comment.

Add Your Comment