|
Posted by Pedro Graca on 01/09/06 21:17
Danny wrote:
> I have used this function.
> $string = strip_tags($p1,'<i><b><u><br><p><font>');
>
> The problem is that the title will be printed as well, but i dont allow the
> title tag.
>
> How to i exclude this ?
remove the title and its contents before applying strip_tags.
<?php
$p1 = '<html><head><title>title</title></head><body><p><a>link with<b>embedded bold</b></a></p></body></html>';
if ((substr_count($p1, '<title>') < 2) && (substr_count($p1, '</title>') < 2)) {
$t1 = strpos($p1, '<title>');
$t2 = strpos($p1, '</title>');
if ($t2 > $t1) {
if ((substr_count($p1, '<head>') < 2) && (substr_count($p1, '</head>') < 2)) {
$h1 = strpos($p1, '<head>');
$h2 = strpos($p1, '</head>');
if (($h2 > $h1) && ($t1 > $h1) && ($t2 < $h2)) {
$p1 = substr($p1, 0, $t1) . substr($p1, $t2+strlen('</title>'));
}
}
}
}
$string = strip_tags($p1,'<i><b><u><br><p><font>');
?>
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
[Back to original message]
|