preg_replace question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel

    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.ph p?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


Working...