note 26627 modified in function.strip-tags by philip

From: Date: Tue, 07 Jan 2003 00:22:37 +0000
Subject: note 26627 modified in function.strip-tags by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-41773@lists.php.net to get a copy of this message
$html_tags = "a|b|i"; $text = preg_replace("'(<)+(/?.+>?)'i", "&lt;\\2", $text); $text = preg_replace("'(&lt;)+(/?\b($html_tags){1}\b>?)'i", "<\\2", $text); This works nice to escape undesireable html tags. However if anyone can merge those 2 regex into a single one it would be appreciated :) --was-- $html_tags = "a|b|i"; $text = preg_replace("'(<)+(/?.+>?)'i", "&lt;\\2", $text); $text = preg_replace("'(&lt;)+(/?\b($html_tags){1}\b>?)'i", "<\\2", $text); This works nice to escape undesireable html tags. However if anyone can merge those 2 regex into a single one it would be appreciated :) ------- My previous post should have been this, as tags like <z <? <% would not be escaped. http://www.php.net/manual/en/function.strip-tags.php

« previous php.notes (#41773) next »