Strip HTML
14
Strip HTML
<?php
// Strips html from string
function StripHTML($strString, $strAllowed = "")
{
// Strip tags
$strString = strip_tags($strString, $strAllowed);
// Remove evil
return preg_replace('/<(.*?)>/ie', "'<'.StripHTMLHelper('\\1').'>'", $strString);
}
// Helper
function StripHTMLHelper($strSource)
{
$strAttrb = "' (style|class)=\"(.*?)\"'i";
$strSource = stripslashes($strSource);
$strSource = preg_replace($strAttrb, '', $strSource);
return $strSource;
}
?>
// Strips html from string
function StripHTML($strString, $strAllowed = "")
{
// Strip tags
$strString = strip_tags($strString, $strAllowed);
// Remove evil
return preg_replace('/<(.*?)>/ie', "'<'.StripHTMLHelper('\\1').'>'", $strString);
}
// Helper
function StripHTMLHelper($strSource)
{
$strAttrb = "' (style|class)=\"(.*?)\"'i";
$strSource = stripslashes($strSource);
$strSource = preg_replace($strAttrb, '', $strSource);
return $strSource;
}
?>






$encoding = 'ISO-8859-1';
$html_less_content = html_entity_decode(strip_tags($html_full_content, ENT_COMPAT, $encoding);
-----------------------
Proud owner of scriptsentials.com and the Scriptsentials network.