#50702 [Opn->Bgs]: strrpos offset argument doesn't work
ID: 50702
Updated by: johannes@php.net
Reported By: samuel dot roze at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Unicode Engine related
Operating System: Debian 5
PHP Version: 5.3.1
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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
Thread (3 messages)