|
Posted by Michael Fesser on 01/10/08 11:46
..oO(Sean Kim)
> From 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.
In a double-quoted string the { cannot be escaped. Try this:
$theTemplate = str_replace('{'.$theKey.'}', $inValues[$theKey],
$theTemplate);
Micha
[Back to original message]
|