I have a string. With "pre" tag inside. I don't want to replace the texts in this pre tag. How can I do that?
<?php
$str="
<b>test</b>
<pre>
<b>test</b>
</pre>
<b>test</b>
";
function htmltobb($str){
$str=preg_replace('(<b>)','[b]',$str);
$str=preg_replace('(</b>)','[/b]',$str);
return $str;
}
echo htmltobb($str);
?>
result:
[b]test[/b]
<pre>
[b]test[/b]
</pre>
[b]test[/b]
what i want?
[b]test[/b]
<pre>
<b>test</b> <-- this line not replaced
</pre>
[b]test[/b]
thank you for all answers