note 81807 deleted from function.preg-replace by felipe

From: Date: Sun, 23 Mar 2008 22:58:37 +0000
Subject: note 81807 deleted from function.preg-replace by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137391@lists.php.net to get a copy of this message
Note Submitter: kyle ---- i came across a function strip_attributes online, looking for a solution to strip attributes after using strip_tags i came up with a quick preg_replace to replace the function that'll remove any formatting (strip all attributes) from ALL tags within the html. i hope this helps somebody: //strip unwanted tags $allowedTags = '<p><span><b><u><i><strong><em>'; $str = strip_tags($str, $allowedTags); //remove all formatting from remaining tags $str = preg_replace('/(<[a-z0-9]+) [^>]*>/', '$1>', $str);

« previous php.notes (#137391) next »