note 92197 modified in function.get-meta-tags by danbrown
| From: | danbrown@php.net | Date: | Tue, 14 Jul 2009 13:38:09 +0000 |
| Subject: | note 92197 modified in function.get-meta-tags by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158269@lists.php.net to get a copy of this message | ||
this function could get each meta of html content , and stripped all js and css.
<?php
function get_meta_data($content)
{
$content = strtolower($content);
$content =
preg_replace("'<style[^>]*>.*</style>'siU",'',$content);
// strip js
$content =
preg_replace("'<script[^>]*>.*</script>'siU",'',$content);
// strip css
$split = explode("\n",$content);
foreach ($split as $k => $v)
{
if (strpos(' '.$v,'<meta')) {
preg_match_all(
"/<meta[^>]+(http\-equiv|name)=\"([^\"]*)\"[^>]" .
"+content=\"([^\"]*)\"[^>]*>/i",
$v, $split_content[],PREG_PATTERN_ORDER);;
}
}
return $split_content;
}
?>
--was--
this function could get each meta of html content , and stripped all js and css.
function get_meta_data($content)
{
$content = strtolower($content);
$content =
preg_replace("'<style[^>]*>.*</style>'siU",'',$content);
// strip js
$content =
preg_replace("'<script[^>]*>.*</script>'siU",'',$content);
// strip css
$split = explode("\n",$content);
foreach ($split as $k => $v)
{
if (strpos(' '.$v,'<meta')) {
preg_match_all(
"/<meta[^>]+(http\-equiv|name)=\"([^\"]*)\"[^>]" .
"+content=\"([^\"]*)\"[^>]*>/i",
$v, $split_content[],PREG_PATTERN_ORDER);;
}
}
return $split_content;
}
http://php.net/manual/en/function.get-meta-tags.php