note 73226 added to function.pathinfo
| From: | corySPAM at lavacube dot com | Date: | Wed, 14 Feb 2007 03:10:15 +0000 |
| Subject: | note 73226 added to function.pathinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123346@lists.php.net to get a copy of this message | ||
Here is my simple alternative to pathinfo using preg_match:
<?php
function path_info( $path )
{
preg_match('/^(.*)\/(.*)(\.(.*))+$/', str_replace('\\', '/',
$path), $matches);
return array( 'dirname' => $matches[1],
'basename' =>
($matches[3]?$matches[2].'.'.$matches[4]:$matches[2]),
'extension' => ($matches[4]?$matches[4]:null),
'filename' => $matches[2] );
}
?>
I'm not the greatest at regular expressions. If I am doing anything wrong, please let me know!
Thanks, and enjoy!
----
Server IP: 216.235.15.211
Probable Submitter: 142.165.95.174
----
Manual Page -- http://www.php.net/manual/en/function.pathinfo.php
Edit -- https://master.php.net/note/edit/73226
Del: integrated -- https://master.php.net/note/delete/73226/integrated
Del: useless -- https://master.php.net/note/delete/73226/useless
Del: bad code -- https://master.php.net/note/delete/73226/bad+code
Del: spam -- https://master.php.net/note/delete/73226/spam
Del: non-english -- https://master.php.net/note/delete/73226/non-english
Del: in docs -- https://master.php.net/note/delete/73226/in+docs
Del: other reasons-- https://master.php.net/note/delete/73226
Reject -- https://master.php.net/note/reject/73226
Search -- https://master.php.net/manage/user-notes.php