Im having problems with preg_replace.
sometimes it doesn't replace.
function code($val,$ni){
$clr[1] = "#E6F5FF";
$clr[0] = "#BEE1FF";
$val = stripslashes(urldecode($val));
$val = preg_replace('/\(quote\sfrom=\"(.*)\"\)/','<br><br><div style="position:relative;width:80%;left:50px;background-color:'.$clr[($ni+1)%2].';border:1px solid;padding:5px;" align=\"left\">Quote<br>originally posted by \\1<img src="bpix.gif" width="90%" height="1"><br>',$val);
$val = preg_replace('/\(\/quote\)/s',"</div>",$val);
$val = str_replace("<editline />","<img src=\"line.gif\" width=\"80%\" align=\"middle\" height=\"1\">",$val);
return $val;
}
$out = code("(quote from=\"user1\")some quote text(/quote)\n\n this is my reply",1);
// works correctly
$out = code("(quote from=\"user2\")(quote from=\"user1\")some quote text(/quote)\n\n this is my reply(/quote) no this doesnt work",1);
// doesn't work: output:
//<br><br><div style="position:relative;width:550px;left:50px;background-color:#E6F5FF;border:1px solid;padding:5px;" align="left">(Quote)<br>originally posted by user2"][quote from="user1<img src="bpix.gif" width="548" height="1"><br>some quote text</div>this is my reply </div> this doesnt work
$out = code("(quote from=\"user2\")\n\n this is my reply(/quote) no this doesnt work(quote from=\"user1\")some quote text[/quote) but this works",1);
// works correctly
echo($out);
Could someone point out the error?
thanks for any help.