note 88512 deleted from function.strip-tags by danbrown

From: Date: Tue, 27 Jan 2009 16:03:14 +0000
Subject: note 88512 deleted from function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149850@lists.php.net to get a copy of this message
Note Submitter: WRB ---- <?php function WRB_strip_tags($text, $allow='<a><span><b><i><s><u><tt><sub><sup>' . '<small><big><em><strong><dfn><code><samp><kbd><var><cite>' . '<del><ins><abbr><acronym><address><q>') { if(preg_match_all('#<table([^>]|.*)>(.*)</table>#si', $text, $found)) { if(is_array($found)) { $text=preg_replace('@<tr([^>]|.*)<t(d|h)([^>]|.*)>(.*)' . '</t(d|h)([^>]|.*)<t(d|h)([^>]|.*)>@siU', '<tr><td>\4: </td><td>', $text); $text=preg_replace('@</t(d|h)><t(d|h)([^>]|.*)>(.*)' . '</t(d|h)([^>]|.*)</tr>@siU', '</td><td>\4, </td></tr>', $text); $text=str_replace(', </td></tr>',' </td></tr>',$text); } } if(preg_match_all('#<dl([^>]|.*)>(.*)</dl>#si', $text, $found)) { if(is_array($found)) { $text=preg_replace('@<dt([^>]|.*)>(.*)</dt>@siU', '<dt>\2: </dt>', $text); $text=preg_replace('@<dd([^>]|.*)>(.*)</dd>@siU', '<dd>\2, </dd>', $text); $text=preg_replace('@<dl(.*), </dd>(.?)</dl>@siU', '<dl\1</dd></dl>', $text); } } if(preg_match_all('#<(o|u)l([^>]|.*)>(.*)</(o|u)l>#si', $text, $found)) { if(is_array($found)) { $text=preg_replace('@<li([^>]|.*)>(.*)</li>@siU', '<li>&bull;\2 </li>', $text); } } $text=preg_replace('/\s\s+/', ' ', trim(strip_tags($text,$allow))); return $text; } ?> I hope that someone is useful :) Example: http://work.n4u.com.pl/strip_tags.php Have a nice day! Regards, Wiktor.

« previous php.notes (#149850) next »