• array_flip -
This function is the opposite function for the get_html_translation_table() function by
reversing HTML special characters back their original string characters.
<?php
$html_text = "Júan and Felípe paid 13¢ a
piece
for gum."
$translation_table = get_html_translation_table(HTML_ENTITIES);
$flipped = array_flip($translation_table);
print strtr($html_text, $flipped);
// The sentence will now read "Júan and Felípe paid 13¢ a piece
for
// gum" without any HTML translation
?>
• strip_tags() -
This function removes all HTML and PHP tags from a string.
<?php
$html_text = "<a href=\"http://www.johnsgifts.com\"><strong>
John's Gifts</strong></a>";
print strip_tags($html_text);
// Returns John's Gifts with no HTML tags
?>
In the even that a tag type should remain while all others are removed, that can be accomplished by
adding the HTML tag in the optional second component of the function.
<?php
$html_text = "<a href=\"http://www.johnsgifts.com\"><strong>
John's Gifts</strong></a>";
print strip_tags($html_text, "<strong>");
// Returns <strong>John's Gifts</strong> but without the <a>
tags
?>
Comments
Post a Comment