Strip all except a few tags : strip_tags « String « PHP






Strip all except a few tags

 
<?
$input = "I <b>love</b> to <a href = \"http://www.java2s.com\">java2s<a>!";
$strip_input = strip_tags($user_input, "<a>");
print_r($strip_input);
?>
  
  








Related examples in the same category

1.strip_tags
2.strip_tags() function removes all HTML and PHP tags from string, leaving only the text entities.
3.strip_tags() function, first argument is the text to transform.
4.strip_tags.php
5.strip_tags.php
6.string strip_tags ( string html_text [, string allowed_tags] ) strips HTML and PHP tags from a string
7.Stripping HTML tags from a string