loadHTML($output); //Load the document into the parse $title = $dom->getElementsByTagName("title")->item(0)->nodeValue; //Title contents //Search for the description tag $metas = $dom->getElementsByTagName("meta"); $descr = ""; //Defaults to empty description foreach ($metas as $item) { if ($item->attributes->getNamedItem('name')->nodeValue == "description") { $descr = $item->attributes->getNamedItem('content')->nodeValue; break; } } //Finish searching for the description tag ?> <?php print($title); ?>