PHP:显示几个html的元描述

时间:2018-01-12 16:05:00

标签: php html meta

我坚持使用代码来显示超过一个html网页的元描述。

此代码显示三次相同的元描述,我想要显示3个不同的元数据。我错了什么?



$kfamily = is_page(683);
  if ($kfamily && get_children(93518)):
$html = file_get_contents_curl("https://".$_SERVER['HTTP_HOST'].$URL['PATH']."/kenfam_00/");
  endif;
  if ($kfamily && get_children(93520)):
$html = file_get_contents_curl("https://".$_SERVER['HTTP_HOST'].$URL['PATH']."/kenfam_01/");
  endif;
 if ($kfamily && get_children(93522)):
$html = file_get_contents_curl("https://".$_SERVER['HTTP_HOST'].$URL['PATH']."/kenfam_02/");
 endif;
 $doc = new DOMDocument();
 @$doc->loadHTML($html);
 $nodes = $doc->getElementsByTagName('title');
 $title = $nodes->item(0)->nodeValue;
 $metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'description')
$description = $meta->getAttribute('content');
}
 $list_pages_html .= '<div class="description-meta">'.$description.'</div>';
&#13;
&#13;
&#13;

0 个答案:

没有答案