Get File Extension

substr($fileName, strrpos($fileName, '.') + 1);

//This function will return the extension of a file.  I have used this to retrieve the extensions of uploaded filenames in a MySQL in order to display an icon appropriate for the file type.

function get_file_extension($fileName) {

$extension = substr($fileName, strrpos($fileName, '.') + 1);
return $extension;

}

//example...

require "path/to/database/connection/";

$sql = mysql_query("SELECT * FROM uploaded_files ") or die("SELECT Error: ".mysql_error());

while ($row = mysql_fetch_array($sql)) {

$fileExtension = get_file_extension($row['fileName'];

if ($fileExtension == 'pdf') {
echo '<img src="/path/to/pdf/icon">' ;
} elseif ($fileExtension == 'jpg') {
echo '<img src="/path/to/jpg/icon">' ;
}

}