note 85123 added to function.basename
| From: | pai dot ravi at yahoo dot com | Date: | Fri, 15 Aug 2008 15:44:12 +0000 |
| Subject: | note 85123 added to function.basename | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143529@lists.php.net to get a copy of this message | ||
once you have extracted the basename from the full path and want to separate the extension from the
file name, the following function will do it efficiently:
function splitFilename($filename)
{
$pos = strrpos($filename, '.');
if ($pos === false)
{ // dot is not found in the filename
return array($filename, ''); // no extension
}
else
{
$basename = substr($filename, 0, $pos);
$extension = substr($filename, $pos+1);
return array($basename, $extension);
}
}
----
Server IP: 203.199.69.133
Probable Submitter: 59.176.44.46
----
Manual Page -- http://www.php.net/manual/en/function.basename.php
Edit -- https://master.php.net/note/edit/85123
Del: integrated -- https://master.php.net/note/delete/85123/integrated
Del: useless -- https://master.php.net/note/delete/85123/useless
Del: bad code -- https://master.php.net/note/delete/85123/bad+code
Del: spam -- https://master.php.net/note/delete/85123/spam
Del: non-english -- https://master.php.net/note/delete/85123/non-english
Del: in docs -- https://master.php.net/note/delete/85123/in+docs
Del: other reasons-- https://master.php.net/note/delete/85123
Reject -- https://master.php.net/note/reject/85123
Search -- https://master.php.net/manage/user-notes.php