3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"; } ?>
based on msQ8J
Output for 5.3.19 - 5.3.29, 5.5.27 - 5.5.35, 5.6.11 - 7.2.0
object(SimpleXMLElement)#4 (2) { ["@attributes"]=> array(2) { ["name"]=> string(3) "two" ["game"]=> string(3) "wow" } [0]=> string(1) "2" }
Output for 5.4.9 - 5.5.26, 5.6.8 - 5.6.10
object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(2) { ["name"]=> string(3) "two" ["game"]=> string(3) "wow" } }