PHP » Strings » strip_tags()

Syntax:
string strip_tags(string s [, string exempt_tags])
s
The string.
exempt_tags
Tags that should not be removed.

Removes html and PHP tags from a string.

This function returns a string with the html and PHP tags removed from the input string. The optional exempt_tags parameter can be used to specify tags that should not be removed from the string.

Examples

Code:
<?php

$s = "This <b>is</b> a <i>string</i> with <font color=\"blue\">some</font> tags.";
$s = strip_tags($s, "<i>");
print htmlspecialchars($s);

?>
Output:
This is a <i>string</i> with some tags.
Explanation:

A string with a few different kinds of tags is stripped of all tags except the italics tag. The result is printed with htmlspecialchars() in order avoid interpretation of the tags.

See Also: