How To Remove Html Tags from String in Php
Posted by Raj
How To Remove Html Tags From String In Php
In this article,I will explain how to remove Html tags from string with php.In php we are using strip_tags function to strip HTML and php tags.
strip_tags function returns a string with HTML and PHP tags stripped from a given string.
strip_tags Syntax:
strip_tags(string $string,string $allowable_tags);
Html tags stripper Example:
<?php
$text = '<span>Test </span><p>Html STripper</p>';
echo strip_tags($text);//Strip full string.
echo "<br>";
echo strip_tags($text, '<p>');//Allow <p> tag
?>
Output:
Test Html Stripper.
Test <p>Html STripper</p>
In this article,I will explain how to remove Html tags from string with php.In php we are using strip_tags function to strip HTML and php tags.
strip_tags function returns a string with HTML and PHP tags stripped from a given string.
strip_tags Syntax:
strip_tags(string $string,string $allowable_tags);
Html tags stripper Example:
<?php
$text = '<span>Test </span><p>Html STripper</p>';
echo strip_tags($text);//Strip full string.
echo "<br>";
echo strip_tags($text, '<p>');//Allow <p> tag
?>
Output:
Test Html Stripper.
Test <p>Html STripper</p>
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
HTML tags,
PHP,
PHP interview questions and answers,
php tags,
remove html tags,
remove tags html,
source codes and tags,
strip html tags,
strip tags
.You can leave a response, or trackback from your own site.