- Forums
- PHP
- How To Remove All the HTML Tags From Text In A PHP Srting
This Page Contains information about How To Remove All the HTML Tags From Text In A PHP Srting By wallpaperama in category PHP with 10 Replies. [1216], Last Updated: Sat May 18, 2024
wallpaperama
Sun Nov 30, 2008
10 Comments
22175 Visits
if you are reading my post, its probably because you want to remove html tags from your posts or forums or whatever.
when i first started to do this, i wanted to remove all the html tags from a strin i had in my posts. this is an example:
<?
$string = "<h1>BIG HTML TAGS</h1>";
?>
ok as you can see, this will output:
BIG HTML TAGS
but i dont want that, i want to stop and prevent html from being posted on my forums. i tried using htmlspecialchars() and htmlentities() but none did what i wanted.
but finally i found it, the function is called strip_tags()
so if i wanted to remove the <h1> tags from my string i would just simply do this:
<?
$string = "<h1>BIG HTML TAGS</h1>";
$string = strip_tags($string);
?>
and this would be the ouput:
BIG HTML TAGS
hope this helps
i.e
<h1>big html tags /h1>