3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file = <<<XML <?xml version="1.0"?> <?xml-stylesheet href="catalog.xsl" type="text/xsl"?> <!DOCTYPE catalog SYSTEM "catalog.dtd"> <catalog> <product description="Cardigan Sweater" id="123" value="" product_image="cardigan.jpg"> <catalog_item gender="Men's"> <size description="Medium"> <color_swatch image="red_cardigan.jpg" id="color" value="Red"/> <color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/> </size> <size description="Large"> <color_swatch image="red_cardigan.jpg" id="color" value="Red"/> <color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/> </size> </catalog_item> </product> </catalog> XML; $xml = simplexml_load_string($file); foreach($xml as $product) { var_dump($product); }
Output for git.master, git.master_jit, rfc.property-hooks
object(SimpleXMLElement)#3 (2) { ["@attributes"]=> array(4) { ["description"]=> string(16) "Cardigan Sweater" ["id"]=> string(3) "123" ["value"]=> string(0) "" ["product_image"]=> string(12) "cardigan.jpg" } ["catalog_item"]=> object(SimpleXMLElement)#4 (2) { ["@attributes"]=> array(1) { ["gender"]=> string(5) "Men's" } ["size"]=> array(2) { [0]=> object(SimpleXMLElement)#5 (2) { ["@attributes"]=> array(1) { ["description"]=> string(6) "Medium" } ["color_swatch"]=> array(2) { [0]=> object(SimpleXMLElement)#7 (1) { ["@attributes"]=> array(3) { ["image"]=> string(16) "red_cardigan.jpg" ["id"]=> string(5) "color" ["value"]=> string(3) "Red" } } [1]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(3) { ["image"]=> string(21) "burgundy_cardigan.jpg" ["id"]=> string(5) "color" ["value"]=> string(8) "burgundy" } } } } [1]=> object(SimpleXMLElement)#6 (2) { ["@attributes"]=> array(1) { ["description"]=> string(5) "Large" } ["color_swatch"]=> array(2) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(3) { ["image"]=> string(16) "red_cardigan.jpg" ["id"]=> string(5) "color" ["value"]=> string(3) "Red" } } [1]=> object(SimpleXMLElement)#7 (1) { ["@attributes"]=> array(3) { ["image"]=> string(21) "burgundy_cardigan.jpg" ["id"]=> string(5) "color" ["value"]=> string(8) "burgundy" } } } } } } }

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:
132.62 ms | 415 KiB | 5 Q