note 85115 added to function.pathinfo
| From: | leons87_AT_hotmail_DOT_com at osu1 dot php dot net | Date: | Fri, 15 Aug 2008 11:47:00 +0000 |
| Subject: | note 85115 added to function.pathinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143520@lists.php.net to get a copy of this message | ||
qutechie at gmail dot com wrote a fix for support for filename in PHP 4; however it gets it wrong
whenever you have a filename with a . in it (so foo.bar.jpg would return foo instead of foo.bar).
A fix would be:
<?php
if(!isset($path_parts['filename'])){
$reversed_filename = strrev( $path_parts['basename'] );
$path_parts['filename'] = strrev( substr( $reversed_filename, strpos( $reversed_filename,
'.' ) + 1 ) );
}
?>
The idea is that you reverse the string and create a substring that starts after the first
'.' and then reverse the result.
----
Server IP: 92.48.74.199
Probable Submitter: 86.133.231.189
----
Manual Page -- http://www.php.net/manual/en/function.pathinfo.php
Edit -- https://master.php.net/note/edit/85115
Del: integrated -- https://master.php.net/note/delete/85115/integrated
Del: useless -- https://master.php.net/note/delete/85115/useless
Del: bad code -- https://master.php.net/note/delete/85115/bad+code
Del: spam -- https://master.php.net/note/delete/85115/spam
Del: non-english -- https://master.php.net/note/delete/85115/non-english
Del: in docs -- https://master.php.net/note/delete/85115/in+docs
Del: other reasons-- https://master.php.net/note/delete/85115
Reject -- https://master.php.net/note/reject/85115
Search -- https://master.php.net/manage/user-notes.php