3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <findit xmlns="http://www.URL.COM" version="8" type="TIX" date="20160323"> <account code="XXXXXX"> <customers> <customer code="12345"> <status code="0">Success</status> <logistic-jobs> <logistic-job id="12345" date="20160324" status="PLA" modified="201603231420"> <number> <number1>479599</number1> <number3>11221</number3> </number> <collection date="20160324" time="0500"> <name>JOHN SMITH</name> <address1>UNIT 3 DAVEY ROAD</address1> <address2>FIELDS END BUSINESS PARK</address2> <address3>GOLDTHORPE</address3> <address4>ROTHERHAM</address4> <address5>S63 0JF</address5> </collection> <delivery date="20160324" time="1200"> <address1>EXAMPLE</address1> <address2>GLENEAFLES FARM</address2> <address3>GLENEAGLES CLOSE</address3> <address4>STANWELL, MIDDLESEX</address4> <address5>TW19 7PD</address5> </delivery> <extra> <address1>45FT C/SIDER</address1> <address2>No</address2> <address4>CEMENT</address4> </extra> <drivers> <driver code="TM1">DAVE SMITH (DAYS)</driver> </drivers> <load weight="27600.00" volume="0.00"> <pallets full="23" half="0" quarter="0" blue="0" oversize="0"/> </load> </logistic-job> </logistic-jobs> </customer> </customers> </account> </findit> XML; $job_simple = simplexml_load_string($xml); if(isset($job_simple->account->customers->customer)) { // Foreach customer in array foreach($job_simple->account->customers->customer as $i => $customer) { // If status is set to success if((string)$customer->status == "Success") { // For each job foreach($customer->{'logistic-jobs'}->{'logistic-job'} as $i => $job) { echo "<ul>\n"; foreach ( $job->drivers->driver as $driver ) { echo "<li> {$driver['code']}: $driver\n"; } echo "</ul>\n"; } } } }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
<ul> <li> TM1: DAVE SMITH (DAYS) </ul>
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: simplexml_load_string() in /in/fljJA on line 49
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.1, 4.4.3 - 4.4.4
Fatal error: Call to undefined function: simplexml_load_string() in /in/fljJA on line 49
Process exited with code 255.
Output for 4.4.2
Fatal error: Call to undefined function: simplexml_load_string() in /in/fljJA on line 50
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: simplexml_load_string() in /in/fljJA on line 49

preferences:
53.61 ms | 409 KiB | 5 Q