Remove Html tags from string PHP – PHP strip_tags() Function

Remove Html tags from string PHP – PHP strip_tags() Function

Today, We want to share with you Remove(Delete) Html tags from string PHP – PHP strip_tags() Function.In this post we will show you wordpress plugin require another plugin, hear for php remove style tag and content, we will give you demo and example for implement.In this post, we will learn about remove script tags from string php with an example.

Remove Html tags from string PHP – PHP strip_tags() Function

There are the Following The simple About Delete Html tags from string PHP – PHP strip_tags() Function Full Information With Example and source code.

As I will cover this Post with live Working example to develop PHP Function to remove specified html tags from string, so the how to remove html tags in php from mysql, is used for this example is following below.

Simple PHP strip_tags() Function



world!“);
?>

This function strips a string from HTML, XML, and PHP tags. In this example, the tag gets stripped.


Remove all html tags from php string

using PHP strip_tags

$data_text = '

Test paragraph.

Other text'; echo strip_tags($data_text); //output Test paragraph. Other data_text

Remove HTML Tags from String using PHP

Use Simple strip_tags( ) to remove HTML and PHP tags from a data strings: Below Examples

Remove all Tags

HDMoives

TamilRokers by TamilMv"; echo strip_tags($data_str, ""); ?>

Output

HDMoives TamilRokers by TamilMv

Remove all Tags with inner Content

/si', trim($tags), $tags); 
        $tags = array_unique($tags[1]); 
        
        if(is_array($tags) AND count($tags) > 0) 
        { 
            if($invert == FALSE) 
            { 
                return preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?@si', '', $text); 
            } 
            else 
            { 
                return preg_replace('@<('. implode('|', $tags) .')\b.*?>.*?@si', '', $text); 
            } 
        } 
        elseif($invert == FALSE) 
        { 
            return preg_replace('@<(\w+)\b.*?>.*?@si', '', $text); 
        } 
        return $text; 
    } 

    $data_str = "

HDMoives

TamilRokers by TamilMv. Thanks for watching"; echo strip_tags_content($data_str, ""); ?>

Output

 TamilRokers by TamilMv. Thanks for watching

Remove Certain Tags

HDMoives

TamilRokers by TamilMv. Thanks for watching"; $tags = array("p", "i"); foreach($tags as $tag) { $data_str = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/", $replace_with, $data_str); } echo $data_str; ?>

Output

HDMoives TamilRokers by TamilMv. Thanks for watching

Remove Certain Tags with Content

HDMoives

TamilRokers by TamilMv. Thanks for watching"; $tags = array("p", "i"); echo preg_replace('#<(' . implode( '|', $tags) . ')(?:[^>]+)?>.*?#s', '', $data_str); ?>

Output

 TamilRokers. Thanks for watching

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Delete Html tags from string PHP – PHP strip_tags() Function.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment