Problem with preg_replace
| From: | James Bogosian | Date: | Sat, 21 Jul 2001 16:37:18 +0000 |
| Subject: | Problem with preg_replace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-59026@lists.php.net to get a copy of this message | ||
Currently, I am parseing a string for href tags and adding a "target=_blank"
to them to have them open up in a new window using this:
$body = preg_replace("<[aA] [hH][rR][eE][fF]=\"(.*?)\">", 'a
href="$1"
target=_blank', $row->body);
This works, to the best of my knowledge, however I was curious if I could
have the target generated based on the url, so that each url would open in
its own window. I decided to try to use the url's md5 to be its target, and
assumed that this would work:
$body = preg_replace("<[aA] [hH][rR][eE][fF]=\"(.*?)\">", 'a
href="$1"
target=' . md5($1), $row->body);
however, I am getting this as an error:
Parse error: parse error, expecting
T_VARIABLE' or '$'' in
index.php on
line 201
Can anyone see what is going wrong here?