Strip HTML





14
Date Submitted Mon. Oct. 10th, 2005 11:05 AM
Revision 1 of 1
Coder mattrmiller
Tags HTML | PHP | String | Strip
Comments 2 comments
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;
        }
?>
 

Matthew R. Miller

www.bluecreststudios.com
=================
Matthew R. Miller

http://bluecreststudios.com
http://www.codeandcoffee.com

Comments

Comments and to replace entities
Thu. Sep. 21st, 2006 1:51 PM    Scripter bertheymans
Comments Site Code?
Wed. Mar. 15th, 2006 12:21 AM    Helper Scriptsentials

Voting