note 73144 added to function.pathinfo
| From: | junk at plaino dot com | Date: | Sat, 10 Feb 2007 10:46:43 +0000 |
| Subject: | note 73144 added to function.pathinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123216@lists.php.net to get a copy of this message | ||
<?php
// PHP compliant with pathinfo():
function path_parts($thePath) {
//
// Output:
//
// if $thePath = "/www/home/file.html";
//
// $Aret['basename'] = file.html;
// $Aret['extension'] = html;
// $Aret['filename'] = file;
// $Aret['dirname'] = /www/home;
//
$thePath = str_replace("\\", "/", $thePath);
$filepathA = explode("/", $thePath);
$filename = array_pop($filepathA);
$filepathB = explode(".", $filename);
$extension = array_pop($filepathB);
$basename = implode(".", $filepathB);
$basePath = join("/", $filepathA);
$Aret = array();
$Aret['basename'] = $filename;
$Aret['extension'] = $extension;
$Aret['filename'] = $basename;
$Aret['dirname'] = $basePath;
return $Aret;
}
print "<pre>";
print_r (path_parts("/www/home/file.html"));
print "</pre>";
?>
----
Server IP: 64.71.164.2
Probable Submitter: 68.101.167.88
----
Manual Page -- http://www.php.net/manual/en/function.pathinfo.php
Edit -- https://master.php.net/note/edit/73144
Del: integrated -- https://master.php.net/note/delete/73144/integrated
Del: useless -- https://master.php.net/note/delete/73144/useless
Del: bad code -- https://master.php.net/note/delete/73144/bad+code
Del: spam -- https://master.php.net/note/delete/73144/spam
Del: non-english -- https://master.php.net/note/delete/73144/non-english
Del: in docs -- https://master.php.net/note/delete/73144/in+docs
Del: other reasons-- https://master.php.net/note/delete/73144
Reject -- https://master.php.net/note/reject/73144
Search -- https://master.php.net/manage/user-notes.php