Page 1 of 1

str_replace problem

Posted: Sun Jul 27, 2008 3:50 pm
by someguyhere
The line of code below is supposed to take a paragraph and replace a particular word in that paragraph with a hyperlinked copy of that word. Everything works except that the url in the link is blank. It is defined earlier in the document and works elsewhere, just not here, so I assume I must have the syntax wrong? What am I missing?

Code: Select all

$par1=str_replace("example","<a href='$url'>$input1[$rand_key1]</a>", $par1);
 

Re: str_replace problem

Posted: Sun Jul 27, 2008 4:23 pm
by califdon
Try

Code: Select all

$par1=str_replace("example","<a href='$url'>" . $input1[$rand_key1] . "</a>", $par1);

Re: str_replace problem

Posted: Sun Jul 27, 2008 4:54 pm
by someguyhere
No, the url is still blank

Re: str_replace problem

Posted: Sun Jul 27, 2008 5:17 pm
by someguyhere
I got it to work.