#33852 [NEW]: Strrpos: offset param works from the end

From: Date: Mon, 25 Jul 2005 09:45:08 +0000
Subject: #33852 [NEW]: Strrpos: offset param works from the end
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969369326@lists.php.net to get a copy of this message
From: sl at yes-co dot nl Operating system: Linux sarge 2.6.8 PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: Strrpos: offset param works from the end Description: ------------ The offset parameter of the strrpos function is the offset from the end of the string. The documentation is unclear about this: "As of PHP 5.0.0 offset may be specified to begin searching an arbitrary number of characters into the string." I would expect it to start at $string+$offset, searching backwards. Reproduce code: --------------- <?php echo "strrpos with offset\n"; $string='abcdefghijklmnopqrstuvwxyz'; echo "string: $string\n"; echo 'strrpos($string, \'n\', 5): '.strrpos($string, 'n', 5)."\n"; echo 'strrpos($string, \'n\', 15): '.strrpos($string, 'n', 15)."\n"; echo 'strrpos($string, \'n\', -5): '.strrpos($string, 'n', -5)."\n"; echo 'strrpos($string, \'n\', -15): '.strrpos($string, 'n', -15)."\n"; ?> Actual result: -------------- strrpos with offset string: abcdefghijklmnopqrstuvwxyz strrpos($string, 'n', 5): 13 strrpos($string, 'n', 15): strrpos($string, 'n', -5): 13 strrpos($string, 'n', -15): -- Edit bug report at http://bugs.php.net/?id=33852&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33852&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33852&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33852&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33852&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33852&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33852&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33852&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33852&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33852&r=support Expected behavior: http://bugs.php.net/fix.php?id=33852&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33852&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33852&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33852&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33852&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33852&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33852&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33852&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33852&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33852&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33852&r=mysqlcfg

« previous php.doc (#969369326) next »