Re: Question about str_replace()

From: Date: Sun, 23 Feb 2003 17:42:11 +0000
Subject: Re: Question about str_replace()
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-136732@lists.php.net to get a copy of this message
That's what's blowing my mind. It is so simple it should work. The php/apache [Zend] on my virtual host just seems to ignore the the brackets. Hans Prins wrote:
Assuming that you do want to replace "[p]" with "<br>", the code you posted worked for me. The following printed: "leadingtext<br>trailingtext" to the screen.... <?php $find = array('& ','W&OD', '"&"', chr(146), '[p]'); $replace = array("&amp; ","W&amp;OD", '"&amp;"', "'", '<br>'); $text = "leadingtext[p]trailingtext"; $words = str_replace ($find, $replace, $text); print $words; ?> "Al" <news@ridersite.org> schreef in bericht news:20030222202643.51197.qmail@pb1.pair.com...
I have a simple str_replace function that obviously has a syntax problem. The [p] in the $find array ignores the brackets. Every "p" in my text is replaced by a <br>. Just for the heck of it, I've tried " instead of ', and preg_replace(), etc. $find= array('& ','W&OD', '"&"', chr(146), '[p]'); $replace= array("&amp; ","W&amp;OD", '"&amp;"', "'", '<br>'); $words= str_replace ($find, $replace, $text); Thanks.....


« previous php.general (#136732) next »