This blog summarizes a plenty of programming tricks coming from Allen's practical project experiences, including PHP, C#, Java, Yii Framework, Lucene...
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);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment