note 81806 deleted from function.preg-replace by nlopess

From: Date: Fri, 14 Mar 2008 15:38:55 +0000
Subject: note 81806 deleted from function.preg-replace by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137066@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 (#137066) next »