471,071 Members | 5,794 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

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 2421

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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.