Bug #1787 Updated: str_replace, ereg_replace problems
| From: | Bug Database | Date: | Wed, 21 Jul 1999 09:28:19 +0000 |
| Subject: | Bug #1787 Updated: str_replace, ereg_replace problems | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-8874@lists.php.net to get a copy of this message | ||
ID: 1787
User Update by: webmaster@softgallery.com
Status: Open
Bug Type: Parser error
Description: str_replace, ereg_replace problems
a simple one for ereg_replace :
echo ereg_replace("\{FOO\}",1,"testtest{FOO}testtest");
does not output testtest1testtest, but testtest.garbagechar.testtest
but echo ereg_replace("\{FOO\}","1","testtest{FOO}testtest");
works normally.
As for str_replace I did not find a test case. This is a quite complex script
and I can't provide it to the mailing list . Here is a bit of the code :
for ($j=0;$j<count($Templates["ParseVars"][$Name]);$j++)
{
$ToReplace = strtoupper($Templates["ParseVars"][$Name][$j]);
$Val = $Vals[strtoupper($ToReplace)];
$Content = str_replace("{$ToReplace}",$Val,$Content);
}
In PHP for example $Content ouputs :
BEFORE
"NOM_CAT" -> "Web Tools"
{CAT_LIEN}{NOM_CAT}
AFTER {CAT_LIEN}Web Tools
With PHP4 :
BEFORE
"NOM_CAT" -> "Web Tools"
{CAT_LIEN}{NOM_CAT}
AFTER {CAT_LIEN}{Web Tools}
I tried to put some strings directly in the varaibles but the function behaved
normally, so perhaps the problem is more complex.
I can provide the code to a PHP developper directly, but it's not commented
and all variables names are french, so it won't be easy to read. Feel free to ask
anyway.
Full Bug description available at: http://bugs.php.net/?id=1787