|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66563 strrchr ignores offset parameter
Submitted: 2014-01-23 22:32 UTC Modified: 2020-03-01 22:16 UTC
From: myselfasunder at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Strings related
PHP Version: 5.4.24 OS: OS X 10.9.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: myselfasunder at gmail dot com
New email:
PHP Version: OS:


 [2014-01-23 22:32 UTC] myselfasunder at gmail dot com
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:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-23 23:19 UTC]
-Type: Bug +Type: Documentation Problem
 [2014-01-23 23:19 UTC]
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
-> 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-24 01:55 UTC] myselfasunder at gmail dot com
Confirmed. Thank you.
 [2020-03-01 22:16 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-03-01 22:16 UTC]
Well, the respective documentation has been improved a while ago,
so I think this ticket can be closed.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 05:01:29 2024 UTC