#50317 [NEW]: strrpos offset behavior is opposite of what docs describe
| From: | codeslinger at compsalot dot com | Date: | Sat, 28 Nov 2009 08:04:38 +0000 |
| Subject: | #50317 [NEW]: strrpos offset behavior is opposite of what docs describe | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-3351@lists.php.net to get a copy of this message | ||
From: codeslinger at compsalot dot com
Operating system:
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: strrpos offset behavior is opposite of what docs describe
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 bug report at http://bugs.php.net/?id=50317&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50317&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50317&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50317&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50317&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50317&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50317&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50317&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50317&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50317&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50317&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50317&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50317&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50317&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50317&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50317&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50317&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50317&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50317&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50317&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50317&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50317&r=mysqlcfg