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); var_dump($xml->foo[0]);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.21, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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) "one" ["game"]=> string(6) "lonely" } [0]=> string(1) "1" }
Output for 5.5.24 - 5.5.26, 5.6.8 - 5.6.10
object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(2) { ["name"]=> string(3) "one" ["game"]=> string(6) "lonely" } }

preferences:
195.89 ms | 402 KiB | 212 Q