You are here: Re: strip Tags problem « PHP Programming Language « IT news, forums, messages
Re: strip Tags problem

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!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация