<?php
$html = '
<span class="phone-number" data-id="999" style="{lots of random stuff here}">+61 9900 0000</span>
<span class="email" data-something="xxx" style="{lots of random stuff here}">test@test.com</span>
';
$dom = new DOMDocument;
$dom->loadHtml($html);
$xpath = new DOMXPath($dom);
$phone = $xpath->query("//span[contains(@class, 'phone-number')]");
$email = $xpath->query("//span[contains(@class, 'email')]");
echo $phone->item(0)->nodeValue.PHP_EOL;
echo $email->item(0)->nodeValue.PHP_EOL;
/*
foreach ($phone as $value) {
echo $value->nodeValue;
}
*/
- Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- +61 9900 0000
test@test.com
preferences:
142.02 ms | 408 KiB | 5 Q