Doc #66563 [Opn]: strrchr ignores offset parameter
| From: | myselfasunder at gmail dot com | Date: | Fri, 24 Jan 2014 01:55:48 +0000 |
| Subject: | Doc #66563 [Opn]: strrchr ignores offset parameter | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10880@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66563&edit=1
ID: 66563
User updated by: myselfasunder at gmail dot com
Reported by: myselfasunder at gmail dot com
Summary: strrchr ignores offset parameter
Status: Open
Type: Documentation Problem
Package: Strings related
Operating System: OS X 10.9.1
PHP Version: 5.4.24
Block user comment: N
Private report: N
New Comment:
Confirmed. Thank you.
Previous Comments:
------------------------------------------------------------------------
[2014-01-23 23:19:27] requinix@php.net
The offset controls the start or end point for the search: positive offset is the ending point,
negative offset is the starting point (from the end). So $offset=5 means to search from the end
towards the beginning as usual but to stop at offset 5, and $offset=-5 means to search from offset
ending-5 to the beginning.
According to that, the documentation should be changed to read like
>offset
-> If specified, search will start this number of characters counted from the
+> If specified, search will end this number of characters counted from the
> beginning of the string. If the value is negative, search will instead start
> from that many characters from the end of the string, searching backwards.
------------------------------------------------------------------------
[2014-01-23 22:32:01] myselfasunder at gmail dot com
Description:
------------
The documentation indicates that the offset describes the number of characters from the front of the
string, and that the search will -start- at the offset and move toward the beginning.
However, the offset seems to be ignored.
Test script:
---------------
$buffer = '01234567890123456789';
var_dump(strrpos($buffer, '0', 5));
Expected result:
----------------
int(0)
Actual result:
--------------
int(10)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66563&edit=1