3v4l.org

run code in 300+ PHP versions simultaneously
<?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; } */

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
265.42 ms | 2548 KiB | 10 Q