#37099 [NEW]: str_replace with arrays - weird behaviour
| From: | admin at ifyouwantblood dot de | Date: | Sun, 16 Apr 2006 18:35:51 +0000 |
| Subject: | #37099 [NEW]: str_replace with arrays - weird behaviour | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-95865@lists.php.net to get a copy of this message | ||
From: admin at ifyouwantblood dot de
Operating system: Linux AND windows
PHP version: 5.1.2
PHP Bug Type: Strings related
Bug description: str_replace with arrays - weird behaviour
Description:
------------
str_replace does not replace all array values with the associated array
replace.
Reproduce code:
---------------
<?php
$string = "test";
test($string);
function test($datei)
{
$search_s=range('a','z');
$replace_s=range('z','a');
$code = str_replace($search_s, $replace_s, $datei);
echo $code."\n";
$decode = str_replace($replace_s, $search_s, $code);
echo $decode;
}
?>
Expected result:
----------------
gvhg
test
Actual result:
--------------
gehg
tvst
--
Edit bug report at http://bugs.php.net/?id=37099&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37099&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37099&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37099&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37099&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37099&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37099&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37099&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37099&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37099&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37099&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37099&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37099&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37099&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37099&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37099&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37099&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37099&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37099&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37099&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37099&r=mysqlcfg