note 73227 deleted from function.pathinfo by nlopess
| From: | nlopess@php.net | Date: | Thu, 15 Feb 2007 13:06:39 +0000 |
| Subject: | note 73227 deleted from function.pathinfo by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123416@lists.php.net to get a copy of this message | ||
Note Submitter: corySPAM at lavacube dot com
----
Oh shoot... not sure what I was thinking there.
Mods, please remove my last post.
Here is the function:
<?php
function path_info( $path )
{
preg_match('/^(.*)\/(.*)[\.](.*)$/', str_replace('\\', '/', $path),
$matches);
return array( 'dirname' => $matches[1],
'basename' => ($matches[3]?$matches[2].'.'.$matches[3]:$matches[2]),
'extension' => ($matches[3]?$matches[3]: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!