3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<img alt="äöü" class="foo" src="bar"><a href="target1">link text 1</a><a class="foo" src="target2">link text 2</a><div class="foo">xxx</div>'; $contentType = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; $doc = new DOMDocument('1.0'); $doc->loadHTML($contentType . $html, LIBXML_NOERROR); $xp = new DOMXPath($doc); foreach ($xp->query('//*[contains(@class, "foo") and (self::a or self::img)]') as $el) { echo $el->ownerDocument->saveHTML($el) . PHP_EOL; }
Output for git.master_jit, git.master, rfc.property-hooks
<img alt="äöü" class="foo" src="bar"> <a class="foo" src="target2">link text 2</a>

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:
34.75 ms | 405 KiB | 5 Q