3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
Array ( [0] => SimpleXMLElement Object ( [0] => 1 ) ) 1 img/primary-nav-logo.pngTommy JenkinCJenkins InsuranceInsurance150 S State StreeLinkend(773) 561-4331Array ( ) Warning: Undefined array key 0 in /in/mm1KL on line 29 No records

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.27 ms | 401 KiB | 8 Q