3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml_string = '<?xml version="1.0"?> <result> <code> <name>Warszawa</name> <lat>52.25</lat> <lng>21.0</lng> <otherDetails>some Warsaw info here</otherDetails> </code> <code> <name>Somewhere Else</name> <lat>42</lat> <lng>99</lng> <otherDetails>some info about somewhere else here</otherDetails> </code> </result> '; $xml = simplexml_load_string($xml_string); echo "\n\n\$xml:\n\n"; print_r($xml); $codeZero = null; foreach ($xml->code->children() as $child) { $codeZero = $child; } echo "\n\n\$codeZero:\n\n"; var_dump($codeZero); $lat = null; foreach ($codeZero->children() as $child) { if (isset($child->lat)) { $lat = $child->lat; } } echo "\n\n\$lat:\n\n"; var_dump($lat);
Output for git.master, git.master_jit, rfc.property-hooks
$xml: SimpleXMLElement Object ( [code] => Array ( [0] => SimpleXMLElement Object ( [name] => Warszawa [lat] => 52.25 [lng] => 21.0 [otherDetails] => some Warsaw info here ) [1] => SimpleXMLElement Object ( [name] => Somewhere Else [lat] => 42 [lng] => 99 [otherDetails] => some info about somewhere else here ) ) ) $codeZero: object(SimpleXMLElement)#5 (1) { [0]=> string(21) "some Warsaw info here" } $lat: NULL

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:
25.32 ms | 407 KiB | 5 Q