3v4l.org

run code in 300+ PHP versions simultaneously
<?php $replacement = 'NEW TEXT'; $dataEditNumber = 2; $html = <<<HTML <p data-edit="1">TEXT A</p> <div not-data-edit="2">TEXT C</div> <div data-edit="2">TEXT B</div> HTML; $dom = new DOMDocument; $dom->loadHTML('<div>' . $html . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query("//*[@data-edit=$dataEditNumber]") as $node) { $node->nodeValue = $replacement; } var_export(substr($dom->saveHTML() ,5, -7));
Output for git.master, git.master_jit, rfc.property-hooks
'<p data-edit="1">TEXT A</p> <div not-data-edit="2">TEXT C</div> <div data-edit="2">NEW TEXT</div>'

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