tutorialtastic

Find File Extension

$ext = array_pop(explode(".",$filename));

$ext = strrchr($filename, ".");

Above are two separate ways to find the extension of a file in PHP, use one or the other. (I believe the second is a fraction of a second faster.)

Be aware that, in validating file types, extensions should not be relied upon as they are easily forged.

Category: PHP
Rating:
Added: 03rd December 07 by Jem
Bookmark At: StumbleUpon, Digg

tutorialtastic — ultimately better than pixelfx
Copyright © Jem Turner 2003-08. (About | Disclaimer | Link In)