3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getValue($html, $tag, $attr) { $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $result = []; foreach ($xpath->query("//{$tag}[@{$attr}]") as $node) { $result[] = $node->getAttribute($attr); } return implode(',', $result); } $html = '<a data-id="777777"></a><a data-id="888888"></a><a data-id="99999"></a>'; $tag = 'a'; $attr = 'data-id'; echo getValue($html, $tag, $attr); echo "\n---\n"; $html = '<a data-A="AAAAAA"></a><a data-A="BBBBBB"></a><a data-A="CCCCCC"></a>'; $tag = 'a'; $attr = 'data-a'; echo getValue($html, $tag, $attr);
Output for git.master, git.master_jit, rfc.property-hooks
777777,888888,99999 --- AAAAAA,BBBBBB,CCCCCC

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