- file_get_contents: documentation ( source)
- mb_convert_encoding: documentation ( source)
- end: documentation ( source)
- strip_tags: documentation ( source)
- explode: documentation ( source)
<?php
$html = file_get_contents('http://www.google.com');
$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
$dom = new DOMDocument;
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$query = $xpath->query("/html/body");
$body = $dom->saveXML($query->item(0));
$body = strip_tags($body);
echo end(explode('Advertising Programs', $body));