You are here: Q: using str_replace to replace braket '{'? « PHP Programming Language « IT news, forums, messages
Q: using str_replace to replace braket '{'?

Posted by Sean Kim on 01/10/08 06:33

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.
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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация