I'm posting a url such as....
http://somewhere.com/link.php?id=2
from a TEXTBOX to my page as the variable name HTMLLinkToReplace called using $HTTP_POST_VARS[HTMLLinkToReplace]
However I'm also posting HTML code from a TEXTAREA with the variable name HTMLCode called using $HTTP_POST_VARS[HTMLCode]
_SNIPIT OF HTML CODE BEING POSTED_
[ - Being posted as TEXTAREA named HTMLCode - ]
<b>Some HTML</b><br>
<u>Some more HTML</u>
<a href="http://somewhere.com/link.php?id=2">A Link</a><br>
<a href="http://somewhere.com/link2.php?id=5">Another Link</a><br>
<a href="http://somewhere.com/link.php?id=2">A second link that shouldn't match the regular expression</a>
_ //END HTML CODE SNIPIT//__
What I'm trying to do is replace the first link that matches $HTTP_POST_VARS[HTMLLinkToReplace] with the preg_replace() function. The reason I choose this function is to replace ONLY the first instance of http://somewhere.com/link.php?id=2 in the $HTTP_POST_VARS[HTMLCode] variable because it has the limit feature.
I thought I might have to use quotemeta to put a \ before all the .'s and the ?'s in the html link before I can use the string in the preg_replace() function, but I just seem to be lost in the fact that every regular expression I try comes nowhere close to working.
I simple want to echo the HTMLCode with the first link that matches HTMLLinkToReplace ... replaced.
Please post replies if I am not explaining myself correctly and how I can better explain.
Sorry for the length,
Charles