note 71402 added to function.strip-tags

From: Date: Mon, 27 Nov 2006 09:40:12 +0000
Subject: note 71402 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-120099@lists.php.net to get a copy of this message
Here is a faster and tested version of strip_selected_tags. Previous example had a small bug that has been fixed now. <?php function strip_selected_tags($text, $tags = array()) { $args = func_get_args(); $text = array_shift($args); $tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags; foreach ($tags as $tag){ if( preg_match_all( '/<'.$tag.'[^>]*>([^<]*)<\/'.$tag.'>/iu', $text, $found) ){ $text = str_replace($found[0],$found[1],$text); } } return preg_replace( '/(<('.join('|',$tags).')(\\n|\\r|.)*\/>)/iu', '', $text); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 83.56.194.1 ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/71402 Del: integrated -- https://master.php.net/note/delete/71402/integrated Del: useless -- https://master.php.net/note/delete/71402/useless Del: bad code -- https://master.php.net/note/delete/71402/bad+code Del: spam -- https://master.php.net/note/delete/71402/spam Del: non-english -- https://master.php.net/note/delete/71402/non-english Del: in docs -- https://master.php.net/note/delete/71402/in+docs Del: other reasons-- https://master.php.net/note/delete/71402 Reject -- https://master.php.net/note/reject/71402 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120099) next »