Q: using str_replace to replace braket "{"?
am 10.01.2008 07:33:50 von Sean KimFrom example in the book 'Programming PHP' (O'Reilly) (p.305)
$theKey = 'DESTINATION';
$target = '{' . $theKey . '}';
$inValues[$theKey] = 'some.php';
//$theTemplate = str_replace("\{$theKey}", $inValues[$theKey],
theTemplate);
//$theTemplate = str_replace("{$theKey}", $inValues[$theKey],
theTemplate);
$theTemplate = str_replace($target, $inValues[$theKey], $theTemplate);
--------------------------
First commented line is from book example but not working.
Second one is also not working too. It replaces string and left '{}'. So
result is '{some.php}'
Third one is my solution and it is working. It gives 'some.php'
But I think there is some way to just use str_replace alone.
Thank you
Sean Kim