PHP Strip tags Advanced
Please help me. I have a script that remove the html tags. It works OK
with some cases such as:
<p>Test</p>
or
<p><b>Test</b></p>
. This is my script:
function safeStrip($text) {
$text = preg_replace('/</', ' <', $text);
$text = preg_replace('/>/', '> ', $text);
$desc = strip_tags($text);
$desc = preg_replace('/ /', ' ', $desc);
return $desc;
}
However if the user type
<pTest</p>
or
<p Test</p>
or
<p>Test/p>
.... The script make my string is blank :( Please help me, If the user
input the html tags (complete or not complete tags). The script will
identify and remove.
Thanks
No comments:
Post a Comment