#50317 [Opn->Csd]: strrpos offset behavior is opposite of what docs describe

From: Date: Sat, 19 Dec 2009 11:01:25 +0000
Subject: #50317 [Opn->Csd]: strrpos offset behavior is opposite of what docs describe
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3515@lists.php.net to get a copy of this message
ID: 50317 Updated by: degeberg@php.net Reported By: codeslinger at compsalot dot com -Status: Open +Status: Closed Bug Type: Documentation problem PHP Version: Irrelevant New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2009-12-19 11:01:07] svn@php.net Automatic comment from SVN on behalf of degeberg Revision: http://svn.php.net/viewvc/?view=revision&revision=292326 Log: Fixed #50317. ------------------------------------------------------------------------ [2009-11-28 08:04:37] codeslinger at compsalot dot com Description: ------------ the actual behavior of the offset for strrpos is exactly the opposite of what the docs lead me to expect. Reproduce code: --------------- --- From manual page: function.strrpos#Description --- Note: As of PHP 5.0.0 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. ================== but what actually happens is that Positive values define the stopping point and Negative values define the starting point. Expected result: ---------------- $foo = "0123456789a123456789b123456789c"; echo strrpos($foo, '7', -5); //claim: stop searching after n chars (from the end of the string) //Expected: 27 || Actual: 17 //============== echo strrpos($foo, '7', 20); //claim: start searching (backwards) n chars into the string. //Expected: 17 || Actual: 27 //============== echo strrpos($foo, '7', 28); //Expected: 27 || Actual: false Actual result: -------------- as you can see from the examples, negative numbers define the point where it *starts* searching backwards offset from the end of the string. and positive numbers define the point from the beginning of the string where it *stops* searching. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50317&edit=1

« previous php.doc.bugs (#3515) next »