3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<DATA <?xml version="1.0" encoding="UTF-8"?> <ns1:catalog xmlns:ns1="http://www.omnichannelintegrationlayer.com/xml/catalog/2016-01-01" catalog-id="at-master-catalog"> <ns1:product product-id="4132002004"> <ns1:min-order-quantity>1</ns1:min-order-quantity> <ns1:step-quantity>1</ns1:step-quantity> <ns1:short-description xmlns:ns2="xml" ns2:lang="de-AT">Jogginghose Cacy jr </ns1:short-description> <ns1:short-description xmlns:ns2="xml" ns2:lang="de-CH">Jogginghose Cacy jr </ns1:short-description> </ns1:product> </ns1:catalog> DATA; $xml = simplexml_load_string($xml); $productid = "4132002004"; $namespaces = $xml->getNamespaces(true); foreach ($xml->xpath("//ns1:product[@product-id='".$productid."']/ns1:short-description") as $short_description) { $langAsString = (string)$short_description->attributes($namespaces['ns2'])->lang; echo $langAsString . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
de-AT de-CH

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:
58.53 ms | 405 KiB | 5 Q