note 88512 added to function.strip-tags

From: Date: Tue, 27 Jan 2009 15:56:10 +0000
Subject: note 88512 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-149847@lists.php.net to get a copy of this message
<?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. ---- Server IP: 82.177.164.100 Probable Submitter: 83.238.121.66 ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/88512 Del: integrated -- https://master.php.net/note/delete/88512/integrated Del: useless -- https://master.php.net/note/delete/88512/useless Del: bad code -- https://master.php.net/note/delete/88512/bad+code Del: spam -- https://master.php.net/note/delete/88512/spam Del: non-english -- https://master.php.net/note/delete/88512/non-english Del: in docs -- https://master.php.net/note/delete/88512/in+docs Del: other reasons-- https://master.php.net/note/delete/88512 Reject -- https://master.php.net/note/reject/88512 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#149847) next »