3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = <<<XML <a> <foo name="one" game="lonely">1</foo> </a> XML; $xml = simplexml_load_string($string); if(!empty($xml->foo[0]->attributes())){ foreach($xml->foo[0]->attributes() as $a => $b) { echo $a,'="',$b,"\"\n"; } } ?>

preferences:
16.74 ms | 402 KiB | 5 Q