note 85196 added to function.pathinfo
| From: | Lostindream at atlas dot cz | Date: | Tue, 19 Aug 2008 20:43:01 +0000 |
| Subject: | note 85196 added to function.pathinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143641@lists.php.net to get a copy of this message | ||
at example from "qutechie at gmail dot com" you can only replace function
'strpos' with 'strrpos'. (strrpos â Find position of last occurrence of a
char in a string)
It's simple. For example:
<?php
function filePath($filePath)
{
$fileParts = pathinfo($filePath);
if(!isset($fileParts['filename']))
{$fileParts['filename'] = substr($fileParts['basename'], 0,
strrpos($fileParts['basename'], '.'));}
return $fileParts;
}
$filePath = filePath('/www/htdocs/index.html');
print_r($filePath);
?>
Output will be:
Array
(
[dirname] => /www/htdocs
[basename] => index.html
[extension] => html
[filename] => index
)
----
Server IP: 147.32.160.17
Probable Submitter: 85.207.178.69
----
Manual Page -- http://www.php.net/manual/en/function.pathinfo.php
Edit -- https://master.php.net/note/edit/85196
Del: integrated -- https://master.php.net/note/delete/85196/integrated
Del: useless -- https://master.php.net/note/delete/85196/useless
Del: bad code -- https://master.php.net/note/delete/85196/bad+code
Del: spam -- https://master.php.net/note/delete/85196/spam
Del: non-english -- https://master.php.net/note/delete/85196/non-english
Del: in docs -- https://master.php.net/note/delete/85196/in+docs
Del: other reasons-- https://master.php.net/note/delete/85196
Reject -- https://master.php.net/note/reject/85196
Search -- https://master.php.net/manage/user-notes.php