3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urlContent = '<li><span><a href="https://site1.com">site1.com</a> : Description 1</span></li> <li><span><a href="https://site2.com">site2.com</a> : Description 2</span></li> <li><span><a href="https://site3.com">site3.com</a> : Description 3</span></li> <li><span><a href="https://site4.com">site4.com</a> : Description 4</span></li>'; $dom = new DOMDocument(); @$dom->loadHTML($urlContent); $xpath = new DOMXPath($dom); $lis = $xpath->evaluate("/html/body/li"); //$li = document.getElementsByTagName("li"); foreach ($lis as $li) { $a = $xpath->evaluate("span/a", $li)->item(0); $url = $a->getAttribute('href'); var_dump($url, trim($a->nextSibling->nodeValue, ' :')); }
Output for git.master, git.master_jit, rfc.property-hooks
string(17) "https://site1.com" string(13) "Description 1" string(17) "https://site2.com" string(13) "Description 2" string(17) "https://site3.com" string(13) "Description 3" string(17) "https://site4.com" string(13) "Description 4"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
29.96 ms | 406 KiB | 5 Q