Help with preg_replace
| From: | John Clegg | Date: | Mon, 19 Jan 2004 16:50:37 +0000 |
| Subject: | Help with preg_replace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-175037@lists.php.net to get a copy of this message | ||
Hi
I am having some problems with preg_replace and I wondering if someone could suggest a fix or explain why it is not working.
Here is the Code:
*********************
<?php
$code = "blah http://www.foo.com/Unsubscribe.php?EmailAddress=[MAIL] blah";
$url = "'http://www.foo.com/maxbid/Unsubscribe.php?EmailAddress=[MAIL]'";
echo "BEFORE : $code<br><br>";
$replace = "Foo";
$code = preg_replace($url,$replace,$code,1);
echo "AFTER: $code<br>";
?>
**********************
Here is the results of the script:
**********************
BEFORE : blah http://www.qxlmaxbid.com/maxbid/Unsubscribe.php?EmailAddress=[MAIL] blah
AFTER: blah http://www.qxlmaxbid.com/maxbid/Unsubscribe.php?EmailAddress=[MAIL] blah
**********************
It should give the following result:
**********************
AFTER: blah Foo blah
**********************
Thanks for your help
Regards
John Clegg