Tuesday 3 April 2012

PHP Remove js, css, head, obj elements...


//remove js,css,head.....
static function cleanElements($html){

$search = array (
   "'<script[^>]*?>.*?</script>'si",  //remove js
   "'<style[^>]*?>.*?</style>'si", //remove css 
   "'<head[^>]*?>.*?</head>'si", //remove head
   "'<link[^>]*?>.*?</link>'si", //remove link
   "'<object[^>]*?>.*?</object>'si"
                      ); 
        $replace = array ( 
          "",
                                   "",
          "",
          "",
          ""
                      );                 
return preg_replace ($search, $replace, $html);
}

No comments:

Post a Comment