Forum Moderators: coopster
I have the following string which holds a bunch of text:
$text = "This is a lot of text containing the word [b]span[/b] and we also have this: <[b]span[/b] style='background-color:yellow;color:#333;font-weight:bold;padding-left:2px;padding-right:2px'>some text containing [b]span[/b]</[b]span[/b]> and some other [b]span[/b] words here and there."; I want to replace pan (not span but only pan) with div but only where it is plain text not HTML or inside tags and the wanted result should be this:
$text = "This is a lot of text containing the word [b]sdiv[/b] and we also have this: <span style='background-color:yellow;color:#333;font-weight:bold;padding-left:2px;padding-right:2px'>some text containing span</span> and some other [b]sdiv[/b] words here and there."; I tried this preg_replace but it is not working correctly:
$text = preg_replace("/([^<\/]pan)/is", "div", $text); Are there anyone who know how I can make this happen?
Kind regards,
Hans Kristian