Removing HTML?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Removing HTML?

Post by dwfait »

How would you check each word to see if it bagan with a < and ended with a >, and then remove those words?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

strip_tags(); - http://www.php.net/strip_tags

Code: Select all

<?php
$a="This is a sentence";
$b="This <b>is</b> a sentence";
$c=strip_tags($b);
echo $a.' - '.strlen($a).'<BR>'.$b.' - '.strlen($b).'<br>'.$c.' - '.strlen($c)
?>
This is a sentence - 18
This is a sentence - 25
This is a sentence - 18
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Well to answer your question: [php_man]ereg[/php_man]() & [php_man]str_replace[/php_man]().

But I recommend the method mentioned by anjanesh.
Post Reply