3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xmlData = '<?xml version="1.0" encoding="ISO-8859-1"?> <agents> <agent> <id>1</id> <image> img/primary-nav-logo.png</image> <name>Tommy Jenkin</name> <company>CJenkins Insurance</company> <street>Insurance150 S State Stree</street> <city>Linkend</city> <phone>(773) 561-4331</phone> </agent> <agent> <id>2</id> <image> img/primary-nav-logo.png</image> <name>Tommy Jenkin</name> <company>CJenkins Insurance</company> <street>Insurance150 S State Stree</street> <city>Linkend</city> <phone>(773) 561-4331</phone> </agent> </agents>'; $xml = simplexml_load_string($xmlData); foreach($xml->xpath('//agent') as $item) { $row = simplexml_load_string($item->asXML()); $v = $row->xpath('//id[. ="1"]'); if($v[0]){ print $item->id; print $item->image; print $item->name; print $item->company; print $item->street; print $item->city; print $item->phone; }else{ echo 'No records'; } }
Output for 5.3.0 - 5.3.29, 5.5.27 - 5.5.35, 5.6.11 - 7.1.0
1 img/primary-nav-logo.pngTommy JenkinCJenkins InsuranceInsurance150 S State StreeLinkend(773) 561-4331 Notice: Undefined offset: 0 in /in/b0ZB6 on line 28 No records
Output for 5.4.0 - 5.5.26, 5.6.8 - 5.6.10
No records Notice: Undefined offset: 0 in /in/b0ZB6 on line 28 No records
Output for 5.0.0 - 5.2.17
1 img/primary-nav-logo.pngTommy JenkinCJenkins InsuranceInsurance150 S State StreeLinkend(773) 561-4331 Notice: Undefined offset: 0 in /in/b0ZB6 on line 28 No records
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: simplexml_load_string() in /in/b0ZB6 on line 24
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: simplexml_load_string() in /in/b0ZB6 on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: simplexml_load_string() in /in/b0ZB6 on line 24