note 86840 added to function.strrchr
| From: | pnoexz at gmail dot com | Date: | Thu, 06 Nov 2008 03:07:39 +0000 |
| Subject: | note 86840 added to function.strrchr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146193@lists.php.net to get a copy of this message | ||
Here is my function that returns the type of a file. I fint it easier to add other types of files,
and simplier than the rest i have seen around.
<?php
function findExt($filename){
$exts = array(
'.jpg' => 'image',
'.png' => 'image',
'.php' => 'php',
'.html' => 'html',
'.swf' => 'flash',
'.gz' => 'compressed',
'.tar' => 'compressed',
);
$ext = strrchr($filename,'.');
if ($exts[$ext]) { return $exts[$ext]; }
else { return "unknown"; }
}
?>
----
Server IP: 190.2.55.3
Probable Submitter: 190.49.26.130
----
Manual Page -- http://www.php.net/manual/en/function.strrchr.php
Edit -- https://master.php.net/note/edit/86840
Del: integrated -- https://master.php.net/note/delete/86840/integrated
Del: useless -- https://master.php.net/note/delete/86840/useless
Del: bad code -- https://master.php.net/note/delete/86840/bad+code
Del: spam -- https://master.php.net/note/delete/86840/spam
Del: non-english -- https://master.php.net/note/delete/86840/non-english
Del: in docs -- https://master.php.net/note/delete/86840/in+docs
Del: other reasons-- https://master.php.net/note/delete/86840
Reject -- https://master.php.net/note/reject/86840
Search -- https://master.php.net/manage/user-notes.php