Possible Duplicate:
php regex <b> to <b>
Inside my admin panel I have a textarea where staff can insert messages to customers.
I want to convert and detect [[p=304_red]]
to two matches within a return. I was thinking str_replace but I cannot do it twice. Also, str_replace would be limited to one, a staff member might add it twice. Anyone recommend a better solution (preg_replace seem tricky and messy)
[[p=304_red]]
Should return
<a href="http://site.com/jump?go=304_red">
<img src="http://cdn.com/304_red/large/1.jpg" />
</a>
My code only returns the URL.
$question = $_GET['replyBoxField'];
$question = str_replace("[[p=", "<a href='http://site.com/jump?go='>", $question);
$question = str_replace("]]", "</a>", $question);