3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Create a DOM Document $dom = new DomDocument(); // Load your HTML $dom->loadHTML('<form class="search-form"> <meta itemprop="target"> <input type="search"> <input type="submit"> </form>'); // Create a new <span> $span = $dom->createElement('span', 'hello'); // Grab the <input elements (we dont have an ID) $inputs = $dom->getElementsByTagName('input'); // Add the <span> between the inputs $inputs->item(0)->parentNode->insertBefore($span, $inputs->item(1)); // By default when you loadHTML(), it generates doctype, html, head, and body tags. remove them! $dom->removeChild($dom->doctype); $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); // Finally get the HTML $html = $dom->saveHTML(); // And output / return / whatever echo $html;
Output for git.master, git.master_jit, rfc.property-hooks
<form class="search-form"> <meta itemprop="target"><input type="search"><span>hello</span><input type="submit"></form>

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:
30.89 ms | 401 KiB | 8 Q