note 58940 added to index
| From: | aktaratservicetenderdotcom at osu1 dot php dot net | Date: | Mon, 21 Nov 2005 17:11:22 +0000 |
| Subject: | note 58940 added to index | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98890@lists.php.net to get a copy of this message | ||
I have noticed that PHP doesn't have a function or construct for getting the file extension.
I made a very simple function to settle that problem.
<?
function get_ext ($filename)
{
$dismantle = explode(".", $filename);
$segments = count($dismantle);
$ext = $dismantle[$segments-1];
return (empty($ext) ? 'invalid' : $ext);
}
//USAGE : get_ext ( str filename)
echo get_ext('aktar.php');
?>
NOTE : if you use this function as is then you should be aware that an invalid file extension will
return the word 'invalid'
----
Manual Page -- http://www.php.net/manual/en/index.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58940
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58940&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58940&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58940&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58940&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58940&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58940&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58940&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58940&report=yes
Search -- http://master.php.net/manage/user-notes.php