Re: Regex to erase HTML tags
| From: | Antonio S. Martins Jr. | Date: | Mon, 27 Nov 2000 17:09:14 +0000 |
| Subject: | Re: Regex to erase HTML tags | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27401@lists.php.net to get a copy of this message | ||
On Mon, 27 Nov 2000, rodrigo wrote:
> I wrote a small function to erase all the html from text in a variable.
> I had to write to regex to do it. I am sure there is a way to do it in
> one line.
>
> Anyone know how to do it?
Yup, try to use: strip_tags()
from: http://www.php.net/manual/function.strip-tags.php
strip_tags
(PHP 3>= 3.0.8, PHP 4 >= 4.0b2)
strip_tags -- Strip HTML and PHP tags from a string
Description
string strip_tags (string str [, string allowable_tags])
This function tries to strip all HTML and PHP tags from the given string.
It errors on the side of caution in case of incomplete or bogus tags. It
uses the same tag stripping state machine as the fgetss() function.
You can use the optional second parameter to specify tags which should not
be stripped.
Note: Allowable_tags was added in PHP 3.0.13, PHP4B3.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Antonio S. Martins Jr. - System Analist | "Only The Shadow Knows |
| WorldNet Internet Maringa - PR - Brasil | what evil lurks in the |
| E-Mail: shadow@wnet.com.br | Heart of Men!" |
| shadow@uem.br | !!! Linux User: 52392 !!! |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
This e-mail message is 100% Microsoft free!
/"\
\ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML
X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
/ \