#50570 [Opn->Bgs]: str_replace doesn't work with URL replacement
| From: | johannes@php.net | Date: | Thu, 24 Dec 2009 16:12:47 +0000 |
| Subject: | #50570 [Opn->Bgs]: str_replace doesn't work with URL replacement | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146091@lists.php.net to get a copy of this message | ||
ID: 50570
Updated by: johannes@php.net
Reported By: julijan dot andjelic at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Streams related
Operating System: Linux Mint 7 (2.6.28-17-generic)
PHP Version: 5.3.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Givenyourcode it will take the string
$str='I love a b c';
And then replace 'a' with 'http://www.example.com/1.html' this gives
$str='I love http://www.example.com/1.html b
c';
then it will replace 'b' with 'http://www.example.com/2.html' so the
result is
$str='I love http://www.example.com/1.html
http://www.example.com/2.html c';
Finally it will replace 'c' with http://www.example.com/3.html, mind
that both URLs include a 'c' in '.com' that will be replaced, too.
so the result is
I love http://www.example.http://www.example.com/3.htmlom/1.html
http://www.example.http://www.example.com/3.htmlom/2.html
http://www.example.com/3.html
Previous Comments:
------------------------------------------------------------------------
[2009-12-24 15:57:01] julijan dot andjelic at gmail dot com
Description:
------------
When using str_replace with 2 arrays and 1 of them contains URL-s the
result gets messed up. I provided a code snippet which shows it.
Reproduce code:
---------------
<?php
$str='I love a b c';
$array0=array('a','b','c');
$array1=array('http://www.example.com/1.html','http://www.example.com/2.html','http://www.example.com/3.html');
echo str_replace($array0, $array1, $str);
?>
Expected result:
----------------
I love http://www.example.com/1.html
http://www.example.com/2.html
http://www.example.com/3.html
Actual result:
--------------
I love http://www.example.http://www.example.com/3.htmlom/1.html
http://www.example.http://www.example.com/3.htmlom/2.html
http://www.example.com/3.html
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50570&edit=1