3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function createNodesFromHTML(DOMDocument $doc,$str) { $nodes = array(); $d = new DOMDocument(); $d->loadHTML("<html>{$str}</html>"); $child = $d->documentElement->firstChild; while($child) { $nodes[] = $doc->importNode($child,true); $child = $child->nextSibling; } return $nodes; } $dom = new DOMDocument(); $icon = '<i class="fa fa-remove"></i>'; $button = $dom->createElement('a'); $button->setAttribute('href', '/offline-bcu/delete/12345'); $button->setAttribute('class', 'ml5 mr5 btn btn-sm btn-danger'); $nodes = createNodesFromHTML($dom, $icon); $button->appendChild($nodes[0]); $dom->appendChild($button); echo $dom->saveHTML();
based on AMDPW
Output for 5.6.0 - 7.3.0rc4
<a href="/offline-bcu/delete/12345" class="ml5 mr5 btn btn-sm btn-danger"><body><i class="fa fa-remove"></i></body></a>