3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlstr = '<?xml version="1.0"?> <catalog> <car> <title>This is car</title> <price>44.95</price> <model>2018</model> <description>An in-depth look at creating applications with XML.</description> </car> <bike> <title>this is bike</title> <price>33.58</price> <description>Just the dummy description</description> </bike> <wheels> <title>this is wheel</title> <price>33.58</price> <description>Just the dummy description</description> </wheels> <bike> <title>this is bike</title> <price>33.58</price> <description>Just the dummy description</description> </bike> </catalog>'; $xml = simplexml_load_string($xmlstr); foreach ($xml->children() as $product) { if ($product->getName() == 'car') { carFunc($product->title, $product->price, $product->model, $product->description); } if ($product->getName() == 'bike') { bikeFunc($product->title, $product->price, $product->description); } if ($product->getName() == 'wheels') { wheelFunc($product->title, $product->price, $product->description); } } function carFunc($title, $price, $model, $description) { echo "Car: $title: It's a $model selling for $price. In detail: $description\n"; } function bikeFunc($title, $price, $description) { echo "Bike: $title: It sells for $price. In detail: $description\n"; } function wheelFunc($title, $price, $description) { echo "Wheel: $title: It sells for $price. In detail: $description\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Car: This is car: It's a 2018 selling for 44.95. In detail: An in-depth look at creating applications with XML. Bike: this is bike: It sells for 33.58. In detail: Just the dummy description Wheel: this is wheel: It sells for 33.58. In detail: Just the dummy description Bike: this is bike: It sells for 33.58. In detail: Just the dummy description

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