3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = <<< EOT <?xml version='1.0' encoding='UTF-8'?> <eveapi version="2"> <currentTime>2013-10-01 18:00:01</currentTime> <closedperiodlist> <!--Zero or more repetitions:--> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-11-11</startdate> <!--Optional:--> <enddate>2014-11-11</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Armistice</closeddescription> <closeddescription locale="fr">Armistice (fr)</closeddescription> <closeddescription locale="nl">Armistice (nl)</closeddescription> <closeddescription locale="de">Armistice (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-11-01</startdate> <!--Optional:--> <enddate>2014-11-01</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">All Saints Day</closeddescription> <closeddescription locale="fr">All Saints Day (fr)</closeddescription> <closeddescription locale="nl">All Saints Day (nl)</closeddescription> <closeddescription locale="de">All Saints Day (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-08-15</startdate> <!--Optional:--> <enddate>2014-08-15</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Assumption of Mary</closeddescription> <closeddescription locale="fr">Assumption of Mary(fr)</closeddescription> <closeddescription locale="nl">Assumption of Mary(nl)</closeddescription> <closeddescription locale="de">Assumption of Mary(de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-07-21</startdate> <!--Optional:--> <enddate>2014-07-21</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">National Holiday</closeddescription> <closeddescription locale="fr">National Holiday (fr)</closeddescription> <closeddescription locale="nl">National Holiday (nl)</closeddescription> <closeddescription locale="de">National Holiday (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-06-09</startdate> <!--Optional:--> <enddate>2014-06-09</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Whitsun Monday</closeddescription> <closeddescription locale="fr">Whitsun Monday (fr)</closeddescription> <closeddescription locale="nl">Whitsun Monday (nl)</closeddescription> <closeddescription locale="de">Whitsun Monday (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-06-08</startdate> <!--Optional:--> <enddate>2014-06-08</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Whitsun</closeddescription> <closeddescription locale="fr">Whitsun (fr)</closeddescription> <closeddescription locale="nl">Whitsun (nl)</closeddescription> <closeddescription locale="de">Whitsun (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-05-29</startdate> <!--Optional:--> <enddate>2014-05-29</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Ascension</closeddescription> <closeddescription locale="fr">Ascension (fr)</closeddescription> <closeddescription locale="nl">Ascension (nl)</closeddescription> <closeddescription locale="de">Ascension (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-05-01</startdate> <!--Optional:--> <enddate>2014-05-01</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Labour day</closeddescription> <closeddescription locale="fr">Labour day (fr)</closeddescription> <closeddescription locale="nl">Labour day (nl)</closeddescription> <closeddescription locale="de">Labour day (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-04-21</startdate> <!--Optional:--> <enddate>2014-04-21</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Easter Monday</closeddescription> <closeddescription locale="fr">Easter Monday (fr)</closeddescription> <closeddescription locale="nl">Easter Monday (nl)</closeddescription> <closeddescription locale="de">Easter Monday (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-04-20</startdate> <!--Optional:--> <enddate>2014-04-20</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">Easter</closeddescription> <closeddescription locale="fr">Easter (fr)</closeddescription> <closeddescription locale="nl">Easter (nl)</closeddescription> <closeddescription locale="de">Easter (de)</closeddescription> </closedperiod> <closedperiod> <openingaudience>PUBLIC</openingaudience> <period> <!--Optional:--> <startdate>2014-01-01</startdate> <!--Optional:--> <enddate>2014-01-01</enddate> </period> <!--1 or more repetitions:--> <closeddescription locale="en">New Year</closeddescription> <closeddescription locale="fr">Nouvelle Annee</closeddescription> <closeddescription locale="nl">Nieuwjaar</closeddescription> <closeddescription locale="de">New Jahr</closeddescription> </closedperiod> </closedperiodlist> <cachedUntil>2013-10-01 18:57:01</cachedUntil> </eveapi> EOT; $simpleXML = simplexml_load_string($xml); // Load XML string data into the simplexml object parser foreach ($simpleXML->result->rowset->row as $row) { $titles = []; $name = $row['name']->__toString(); foreach($row as $attrib){ if($attrib['name']->__toString() === 'titles'){ foreach($attrib as $title){ $titles[] = $title['titleName']->__toString(); } } } echo $name . ' : ' . implode(' - ', $titles) . "<br/>\n"; }
Output for 5.4.0 - 7.1.0
Notice: Trying to get property of non-object in /in/Lb0Gb on line 169 Warning: Invalid argument supplied for foreach() in /in/Lb0Gb on line 169
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Lb0Gb on line 170
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected '[' in /in/Lb0Gb on line 171
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/Lb0Gb on line 170
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Lb0Gb on line 170
Process exited with code 255.