From: o_eclipse at mail dot ru
Operating system: Windows
PHP version: 5.0.5
PHP Bug Type: Unknown/Other Function
Bug description: error in str_replace/str_ireplace with array type arguments
Description:
------------
Functions str_replace / str_ireplace give incorrect result when 'replace'
argument is array filled with numbers.
Reproduce code:
---------------
<?php
$subject = "*0-1-2-3-4-5-6-7-8-9*";
$search = array ( "-", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
);
$replace = array ( "+", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"
);
$result = str_replace($search, $replace, $subject);
echo "$result\n"; // result is *a+b+c+d+e+f+g+h+i+j*
$replace = array ( "+", "9", "8", "7", "6", "5", "4", "3", "2", "1", "0"
);
$result = str_replace($search, $replace, $subject);
echo "$result\n"; // result is *0+1+2+3+4+4+3+2+1+0*
// must be *0+1+2+3+4+5+6+7+8+9*
?>
Expected result:
----------------
the program output should be like this:
*a+b+c+d+e+f+g+h+i+j*
*0+1+2+3+4+5+6+7+8+9*
Actual result:
--------------
that`s what we get:
*a+b+c+d+e+f+g+h+i+j*
*0+1+2+3+4+4+3+2+1+0*
--
Edit bug report at http://bugs.php.net/?id=35232&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35232&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=35232&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=35232&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=35232&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35232&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35232&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35232&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35232&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35232&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35232&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=35232&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=35232&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35232&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35232&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35232&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35232&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35232&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35232&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35232&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35232&r=mysqlcfg