note 15913 modified in function.strip-tags by vrana

From: Date: Mon, 22 Dec 2003 16:29:05 +0000
Subject: note 15913 modified in function.strip-tags by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62338@lists.php.net to get a copy of this message
This function seems to work for me. Allowable tags are '<b><i><u><a>', and it strips out all parameters except for HREFs. function safeHTML($text) { $text = stripslashes($text); $text = strip_tags($text, '<b><i><u><a>'); $text = eregi_replace ("<a [^>]*href *= *([^ ]+)[^>]*>", "<a href=\\1>", $text); $text = eregi_replace ("<([b|i|u])[^>]*>", "<\\1>", $text); return $text; } --was-- This function seems to work for me. Allowable tags are '<b><i><u><a>', and it strips out all parameters except for HREFs. function safeHTML($text) { $text = stripslashes($text); $text = strip_tags($text, '<b><i><u><a>'); $text = ereg_replace ("<a[^>]+href *= *([^ ]+)[^>]*>", "<a href=\\1>", $text); $text = ereg_replace ("<([b|i|u])[^>]*>", "<\\1>", $text); return $text; } http://www.php.net/manual/en/function.strip-tags.php

« previous php.notes (#62338) next »