468,738 Members | 2,531 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

preg_replace question

Hi,

I want to turn the following:

<ref>Name & Name2, 1999</ref>

into

<a href="index.php?ref=Name + Name2, 1999">Name & Name2, 1999</a>

I now have to following code:

$text = preg_replace("/<ref>([^<]+)<\/ref>/m","<a
href=\"index.php?ref=\\1\">\\1</a>",$text);

The problem is that &-sign are not converted to + sign. That is really
needed because & marks the end of the variable $ref

How can I improve this function so that the replacement works like I want it
to?

- Daniel
Jul 16 '05 #1
0 2317

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by JDJones | last post: by
1 post views Thread by yawnmoth | last post: by
7 posts views Thread by Margaret MacDonald | last post: by
4 posts views Thread by leegold2 | last post: by
9 posts views Thread by ihatzi | last post: by
3 posts views Thread by Charles | last post: by
5 posts views Thread by julianmlp | last post: by
1 post views Thread by otrWalter | last post: by
10 posts views Thread by deko | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.