note 72114 added to function.pathinfo
| From: | Microphage71 at osu1 dot php dot net | Date: | Wed, 03 Jan 2007 12:21:42 +0000 |
| Subject: | note 72114 added to function.pathinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121237@lists.php.net to get a copy of this message | ||
function pathInfos ($path)
{
$tab = pathinfo($path);
$tab['dirname'] = str_replace ('.', './',
$tab['dirname']);
if (strstr (PHP_OS, 'WIN'))
{
$tab['dirname'] = str_replace ('\\', '/',
$tab['dirname']);
}
if ($tab['dirname'] == '')
{
$tab['dirname'] = './';
}
if (substr ($tab['dirname'], strlen ($tab['dirname']) - 1, 1) !=
'/')
{
$tab['dirname'] .= '/';
}
if (strpos ($tab['basename'], '.') !== false)
{
$tab['filename'] = substr ($tab['basename'], 0, strpos
($tab['basename'], '.'));
$tab['extension'] = substr ($tab['basename'], strpos
($tab['basename'], '.') + 1);
}
else
{
$tab['extension'] = '';
}
return $tab;
}
ex 1:
-----
echo print_r (pathInfos ('/a/b/c'));
Array
(
[dirname] => /a/b/
[basename] => c
[filename] => c
[extension] =>
)
ex 2:
-----
echo print_r (pathInfos ('/a/b/c.tar'));
Array
(
[dirname] => /a/b/
[basename] => c.tar
[filename] => c
[extension] => tar
)
ex 3:
-----
echo print_r (pathInfos ('c.tar.gz'));
Array
(
[dirname] => ./
[basename] => c.tar.gz
[filename] => c
[extension] => tar.gz
)
----
Server IP: 217.174.196.197
Probable Submitter: 193.252.59.207
----
Manual Page -- http://www.php.net/manual/en/function.pathinfo.php
Edit -- https://master.php.net/note/edit/72114
Del: integrated -- https://master.php.net/note/delete/72114/integrated
Del: useless -- https://master.php.net/note/delete/72114/useless
Del: bad code -- https://master.php.net/note/delete/72114/bad+code
Del: spam -- https://master.php.net/note/delete/72114/spam
Del: non-english -- https://master.php.net/note/delete/72114/non-english
Del: in docs -- https://master.php.net/note/delete/72114/in+docs
Del: other reasons-- https://master.php.net/note/delete/72114
Reject -- https://master.php.net/note/reject/72114
Search -- https://master.php.net/manage/user-notes.php