- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
function renderHTML($doc)
{
return preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>','<head>','</head>'), array('', '', '', ''), $doc->saveHTML()));
}
function reorder($str)
{
$dom = new DOMDocument;
$dom->loadHTML($str);
$path = new DOMXPath($dom);
$_res = $path->query('.//meta[@name="description"]');
$elem = $_res->item(0);
$desc = $dom->saveHTML($elem)."\r\n";
$elem->parentNode->removeChild($elem);
$_res = $path->query('.//meta[@name="keywords"]');
$elem = $_res->item(0);
$desc .= $dom->saveHTML($elem)."\r\n";
$elem->parentNode->removeChild($elem);
$preReady = renderHTML($dom);
$arTmp = explode("</title>",$preReady);
$ready = $arTmp[0]."</title>".$desc.$arTmp[1];
return $ready;
}
Комментарии (0) RSS
Добавить комментарий