3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = <<<XML <a> <foo name="one" game="lonely">1</foo> <foo name="two" game="wow">2</foo> </a> XML; $xml = simplexml_load_string($string); var_dump($xml->foo[1]);exit; $xml = simplexml_load_string($string); foreach($xml->foo->attributes() as $a => $b) { echo $a,'="',$b,"\"\n"; } ?>
Output for 5.5.27 - 5.5.35, 5.6.11 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
object(SimpleXMLElement)#4 (2) { ["@attributes"]=> array(2) { ["name"]=> string(3) "two" ["game"]=> string(3) "wow" } [0]=> string(1) "2" }
Output for 5.5.24 - 5.5.26, 5.6.8 - 5.6.10
object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(2) { ["name"]=> string(3) "two" ["game"]=> string(3) "wow" } }

preferences:
171.68 ms | 402 KiB | 183 Q