Web Hosting Talk







View Full Version : Anyone have a html stripper in php handy?


Joor
12-11-2002, 09:31 PM
I am looking for a regular expressions function that will strip the html when I pass a variable through it. I have one for asp, but I am just making my move over to php and google has not turned one up. Just hoping that someone may have one laying around. TIA

ServerCorps
12-11-2002, 09:35 PM
vb regex patterns dont work in php?

Khaless
12-11-2002, 09:35 PM
http://www.php.net/manual/en/function.htmlspecialchars.php

or

http://www.php.net/manual/en/function.preg-replace.php can be done quite well using PERL regular Expressions, u prolly want to look at example 3 and the comments.

sasha
12-11-2002, 09:43 PM
<edit>
too slow
</edit>

Joor
12-11-2002, 09:45 PM
Yeah, this looks perfect, funny how I didn't goto php.net at either. I am working on #3 and still having trouble, but that is the code I needed. Thank you all very much.

Khaless
12-11-2002, 09:48 PM
np.. lol @ sasha :stickout:

allera
12-11-2002, 09:51 PM
Hrm... what about

http://www.php.net/manual/en/function.strip-tags.php

"strip_tags -- Strip HTML and PHP tags from a string"

That's what I use anyway...

Joor
12-11-2002, 10:15 PM
The #3 has solved my problems to a T. Does look a little unoptimized but beggers can't be choosers :). Thanks for the tips.

Khaless
12-11-2002, 10:35 PM
well it runs better then the PHP Regular Expressions :P

Joor
12-11-2002, 10:39 PM
lol, yeah it sure beats the pants off of them. I am still waiting for them to be compiled in :P