3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <condition type="or"> <event objType="s" objectId="144" eventType="tr" event="triggered"/> <event objType="s" objectId="149" eventType="tr" event="triggered"/> <event objType="s" objectId="159" eventType="tr" event="triggered"/> <event objType="s" objectId="160" eventType="tr" event="triggered"/> <event objType="s" objectId="145" eventType="tr" event="triggered"/> </condition>'; $obj = new SimpleXMLIterator($xml); foreach ($obj->event as $event) { var_dump($event, $event->{'@attributes'}); //echo $event->{'@attributes'}['objectId'] . '<br/>'; }
Output for 5.1.2, 5.2.1 - 5.6.28, 7.0.0 - 7.1.0
object(SimpleXMLIterator)#4 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "144" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "149" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#4 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "159" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "160" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#4 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "145" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#5 (0) { }
Output for hhvm-3.10.0 - 3.12.0
object(SimpleXMLIterator)#3 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "144" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#4 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "149" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "159" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#6 (0) { } object(SimpleXMLIterator)#6 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "160" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#7 (0) { } object(SimpleXMLIterator)#7 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "145" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#8 (0) { }
Output for 5.1.3 - 5.2.0
object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "144" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#6 (0) { } object(SimpleXMLIterator)#6 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "149" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "159" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#6 (0) { } object(SimpleXMLIterator)#6 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "160" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(4) { ["objType"]=> string(1) "s" ["objectId"]=> string(3) "145" ["eventType"]=> string(2) "tr" ["event"]=> string(9) "triggered" } } object(SimpleXMLIterator)#6 (0) { }
Output for 5.0.0 - 5.1.1
object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#5 (0) { } object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#4 (0) { } object(SimpleXMLIterator)#5 (0) { }
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/CE4QB on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/CE4QB on line 11