#50702 [Bgs]: strrpos offset argument doesn't work
| From: | samuel dot roze at gmail dot com | Date: | Sat, 09 Jan 2010 09:47:31 +0000 |
| Subject: | #50702 [Bgs]: strrpos offset argument doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146477@lists.php.net to get a copy of this message | ||
ID: 50702
User updated by: samuel dot roze at gmail dot com
Reported By: samuel dot roze at gmail dot com
Status: Bogus
Bug Type: Unicode Engine related
Operating System: Debian 5
PHP Version: 5.3.1
New Comment:
Oh! I'm really sorry. I thought that $offset was the number of
characters that are forgotten at the end of the string.
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2010-01-09 03:28:34] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You are searching for the last occurrence starting at position 20,
which is still the last. You have to use -20 as offset. Please mind the
strrpos documentation:
offset: May be specified to begin searching an arbitrary number of
characters into the string. Negative values will stop searching at an
arbitrary point prior to the end of the string.
http://php.net/strrpos
------------------------------------------------------------------------
[2010-01-08 22:41:19] samuel dot roze at gmail dot com
Description:
------------
The third sttrpos argument, $offset, doesn't act on data. With are
without it, it is the same result.
Reproduce code:
---------------
<?php
$file_path = '/home/mon/fichier/LC_MESSAGES/message.po';
var_dump($file_path);
$last_bracket = strrpos($file_path, '/');
var_dump($last_bracket);
$last_bracket2 = strripos($file_path, '/', 20);
var_dump($last_bracket2);
?>
Expected result:
----------------
string(40) "/home/mon/fichier/LC_MESSAGES/message.po"
int(29)
int(17)
Actual result:
--------------
string(40) "/home/mon/fichier/LC_MESSAGES/message.po"
int(29)
int(29)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50702&edit=1