note 11952 added to function.filetype.php
| From: | mnc-php at u dot nu | Date: | Thu, 15 Mar 2001 00:56:27 +0000 |
| Subject: | note 11952 added to function.filetype.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-12410@lists.php.net to get a copy of this message | ||
Here's what may be a better way to get the extension off a file name (this one deals properly
with names like 'file.tar.gz', 'file.tar.', 'file', and so on):
$extension = '';
$parts = split('\.', $file_name);
if (count($parts) > 1) $extension = end($parts);
if (!$extension && count($parts) > 2) $ext = prev($parts);
http://www.php.net/manual/en/function.filetype.php