3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = ' <users> <learner name="John"> <rater name="John" email="john@domain.com" group="Self"></rater> <rater name="Jane" email="jane@domain.com" group="Manager"></rater> <rater name="Nathan" email="nathan@domain.com" group="Peers"></rater> </learner> <learner name="Jane"> <rater name="Jane" email="jane@domain.com" group="Self"></rater> <rater name="John" email="john@domain.com" group="Peers"></rater> <rater name="Nathan" email="nathan@domain.com" group="Others"></rater> </learner> </users> '; $sxe = simplexml_load_string($xml); foreach($sxe as $learner){ $name = $learner->attributes()['name']; echo "Learner $name\n"; foreach($learner->rater as $rater){ foreach($rater->attributes() as $key => $value){ echo " - $key = $value\n"; } } }
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Learner John - name = John - email = john@domain.com - group = Self - name = Jane - email = jane@domain.com - group = Manager - name = Nathan - email = nathan@domain.com - group = Peers Learner Jane - name = Jane - email = jane@domain.com - group = Self - name = John - email = john@domain.com - group = Peers - name = Nathan - email = nathan@domain.com - group = Others
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/0vcde on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/0vcde on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/0vcde on line 20
Process exited with code 255.