3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = " <root> <parent> <child name='Child1' /> <child name='Child2' /> <subparent> <child name='Child3' /> </subparent> </parent> <child name='Child4' /> </root>"; $xml = simplexml_load_string( $xml); foreach( $xml->xpath( './/child') as $child) { var_dump($child); echo $child->attributes()['name'] . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
object(SimpleXMLElement)#2 (1) { ["@attributes"]=> array(1) { ["name"]=> string(6) "Child1" } } Child1 object(SimpleXMLElement)#3 (1) { ["@attributes"]=> array(1) { ["name"]=> string(6) "Child2" } } Child2 object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(1) { ["name"]=> string(6) "Child3" } } Child3 object(SimpleXMLElement)#5 (1) { ["@attributes"]=> array(1) { ["name"]=> string(6) "Child4" } } Child4

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:
50.21 ms | 402 KiB | 8 Q