- var_dump: documentation ( source)
- libxml_use_internal_errors: documentation ( source)
<?php
$html = '<h2><span id="History"></span><span class="mw-headline" id="History">History</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Adamantina&veaction=edit&section=1" class="mw-editsection-visualeditor" title="Editar secção: History">editar</a><span class="mw-editsection-divider"> | </span><a href="/w/index.php?title=Adamantina&action=edit&section=1" title="Editar secção: History">editar código-fonte</a><span class="mw-editsection-bracket">]</span></span></h2>';
$d = new DOMDocument;
libxml_use_internal_errors(true);
$d->loadHTML($html);
$domxpath = new DOMXPath($d);
$paragraph = $domxpath->query('//h2/*[contains(text(), "History")]');
var_dump($paragraph->length);
if ($paragraph->length > 0) {
echo "Results!";
}
else {
echo "Not contained";
}