#40863 [NEW]: str_ireplace not behaving as expected
| From: | jonathan at sadowski dot us | Date: | Tue, 20 Mar 2007 10:10:33 +0000 |
| Subject: | #40863 [NEW]: str_ireplace not behaving as expected | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-110547@lists.php.net to get a copy of this message | ||
From: jonathan at sadowski dot us
Operating system: Ubuntu
PHP version: 5.2.1
PHP Bug Type: Strings related
Bug description: str_ireplace not behaving as expected
Description:
------------
str_ireplace doesn't behave as expected when $search and $replace are
equally sized arrays, and $subject is a string containing mixed case.
Reproduce code:
---------------
<?php
$phrase = "We the People of the United States";
$letters = explode(" ","A B C D E F G H I J K L M N O P Q R S T U V W X Y
Z");
$key = $letters;
shuffle($key);
echo sizeof($letters) . "\n" . sizeof($key) . "\n\n";
echo implode(" ",$letters) . "\n" . implode(" ",$key) . "\n"
.
str_ireplace($letters,$key,$phrase);
?>
Expected result:
----------------
26
26
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
V T U O W Q E X Y K S D Z B M A I L J R C F G H P N
GW RXW AWMADW MQ RXW CBYRWO JRVRWJ
Actual result:
--------------
26
26
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
V T U O W Q E X Y K S D Z B M A I L J R C F G H P N
GG RHG AGMADG MI RHG CBPRGM JRFRGJ
--
Edit bug report at http://bugs.php.net/?id=40863&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40863&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40863&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40863&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40863&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40863&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40863&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40863&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40863&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40863&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40863&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40863&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40863&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40863&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40863&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40863&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40863&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40863&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40863&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40863&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40863&r=mysqlcfg