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"]'); print_r($v); 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.38, 5.6.11 - 5.6.28, 7.0.0 - 7.1.0
Array ( [0] => SimpleXMLElement Object ( [0] => 1 ) ) 1 img/primary-nav-logo.pngTommy JenkinCJenkins InsuranceInsurance150 S State StreeLinkend(773) 561-4331Array ( ) Notice: Undefined offset: 0 in /in/mm1KL on line 29 No records
Output for hhvm-3.12.0
Array ( [0] => SimpleXMLElement Object ( [0] => 1 ) ) 1 img/primary-nav-logo.pngTommy JenkinCJenkins InsuranceInsurance150 S State StreeLinkend(773) 561-4331Array ( ) Notice: Undefined index: 0 in /in/mm1KL on line 29 No records
Output for hhvm-3.10.0
Array ( [0] => SimpleXMLElement Object ( ) ) No recordsArray ( ) Notice: Undefined index: 0 in /in/mm1KL on line 29 No records
Output for 5.4.0 - 5.5.26, 5.6.0 - 5.6.10
Array ( [0] => SimpleXMLElement Object ( ) ) No recordsArray ( ) Notice: Undefined offset: 0 in /in/mm1KL on line 29 No records
Output for 5.0.0 - 5.2.17
Array ( [0] => SimpleXMLElement Object ( [0] => 1 ) ) 1 img/primary-nav-logo.pngTommy JenkinCJenkins InsuranceInsurance150 S State StreeLinkend(773) 561-4331Array ( ) Notice: Undefined offset: 0 in /in/mm1KL on line 29 No records
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: simplexml_load_string() in /in/mm1KL 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/mm1KL 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/mm1KL on line 24