Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

Remove html tags from a string wtih PHP

Sometimes you don't need any formatting. That's just a nice way to remove all the html tags.

Remove all tags:

    function removeTags($str) {  
        $str = preg_replace("#<(.*)/(.*)>#iUs", "", $str);
        return $str;
    }
    

Remove a specific tag:

    function removeTag($str, $tag) { 
        $str = preg_replace("#\\<".$tag."(.*)/".$tag.">#iUs", "", $str);
        return $str;
    }
If you enjoy this post, share it on Twitter, Facebook or LinkedIn.