note 70046 deleted from function.strip-tags by danbrown

From: Date: Sun, 17 May 2009 15:58:43 +0000
Subject: note 70046 deleted from function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154729@lists.php.net to get a copy of this message
Note Submitter: magdolen at elepha dot info ---- i edited strip_selected_tags function that salavert created to strip also single tags (xhtml only) here it is also with metric modification: function strip_selected_tags($text, $tags = array()) { $args = func_get_args(); // metric edit $text = preg_replace("/\r\n|\n|\r/","",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); } // hrax edit if(preg_match_all('/<'.$tag.'.*\/>/iU', $text, $found)){ $text = str_replace($found[0], "", $text); } } return $text; }

« previous php.notes (#154729) next »