3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<ul><li><a href="test.php">Test</a>(10)</li></ul>'; echo $string; $dom_document = new DOMDocument(); $dom_document->loadHTML($string); $new_string = ""; foreach($dom_document->getElementsByTagName('ul') as $ul){ // For all ul. $new_string .= "<ul>"; foreach($ul->childNodes as $li){ // For all li. $new_string .= "<li>"; $i=0; foreach($li->childNodes as $a){ if(isset($a->attributes[0]->value)){ $href = $a->attributes[0]->value; } if($i===0){ $new_string .= '<a href="'.$href.'">'; } $new_string .= $a->nodeValue; $i++; } $new_string .= "</a>"; $new_string .= "</li>"; } $new_string .= "</ul>"; } echo $new_string; ?>
Output for git.master, git.master_jit, rfc.property-hooks
<ul><li><a href="test.php">Test</a>(10)</li></ul><ul><li><a href="test.php">Test(10)</a></li></ul>

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