find the file name extension of a file - Php
Get file extension
Snippet Code
This function is used to find the extension of file
<?php
function getExt($filenames) {
if (!is_array($filenames)) {
$filenames = (array) $filenames;
}
foreach ($filenames as $key => $value) {
$output[$value] = end(explode('.', $value));
}
return $output;
}
$array=array('a.txt','b.doc','c.xml');
getExt($array);
?>
Tags