3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = <<<XML <?xml version="1.0" encoding="UTF-8" ?> <root> <ARTICLEDATA> <ARTICLE> <A_PRICEDATA> <A_PRICE channel="1" currency="EUR"> <A_VK>34.95</A_VK> </A_PRICE> </A_PRICEDATA> <A_MEDIADATA> <A_MEDIA type="image" origname="9990.jpg">https://1.jpg</A_MEDIA> <A_MEDIA type="image" origname="11260.jpg">https://2.jpg</A_MEDIA> <A_MEDIA type="image" origname="12294.jpg">https://3.jpg</A_MEDIA> <A_MEDIA type="image" origname="13306.jpg">https://4.jpg</A_MEDIA> <A_MEDIA type="image" origname="13012.jpg">https://5.jpg</A_MEDIA> <A_MEDIA type="image" origname="13760.jpg">https://6.jpg</A_MEDIA> </A_MEDIADATA> </ARTICLE> <ARTICLE> <A_PRICEDATA> <A_PRICE channel="1" currency="EUR"> <A_VK>19.95</A_VK> </A_PRICE> </A_PRICEDATA> <A_MEDIADATA> <A_MEDIA type="image" origname="9990.jpg">https://10.jpg</A_MEDIA> <A_MEDIA type="image" origname="11260.jpg">https://2.jpg</A_MEDIA> <A_MEDIA type="image" origname="12294.jpg">https://3.jpg</A_MEDIA> <A_MEDIA type="image" origname="13306.jpg">https://4.jpg</A_MEDIA> <A_MEDIA type="image" origname="13012.jpg">https://5.jpg</A_MEDIA> <A_MEDIA type="image" origname="13760.jpg">https://6.jpg</A_MEDIA> </A_MEDIADATA> </ARTICLE> </ARTICLEDATA> </root> XML; $xml = simplexml_load_string($str); $articles = ""; foreach ($xml->ARTICLEDATA->ARTICLE as $article) { $price = (string)$article->A_PRICEDATA->A_PRICE->A_VK; $firstImage = (string)$article->A_MEDIADATA->A_MEDIA[0]; $produkt = "Product 1"; $articles .= '<div class="photo"><img src="' . $firstImage . '" style="width: 120px margin:5px;"><div class="product-info mt__15"><h3 class="product-title pr fs__14 mg__0 fwm">' . $produkt . '</h3><span class="price">€' . $price . ' EUR</span></div></div>'; } echo $articles;
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.4, 8.3.6 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.7
<div class="photo"><img src="https://1.jpg" style="width: 120px margin:5px;"><div class="product-info mt__15"><h3 class="product-title pr fs__14 mg__0 fwm">Product 1</h3><span class="price">€34.95 EUR</span></div></div><div class="photo"><img src="https://10.jpg" style="width: 120px margin:5px;"><div class="product-info mt__15"><h3 class="product-title pr fs__14 mg__0 fwm">Product 1</h3><span class="price">€19.95 EUR</span></div></div>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <div class="photo"><img src="https://1.jpg" style="width: 120px margin:5px;"><div class="product-info mt__15"><h3 class="product-title pr fs__14 mg__0 fwm">Product 1</h3><span class="price">€34.95 EUR</span></div></div><div class="photo"><img src="https://10.jpg" style="width: 120px margin:5px;"><div class="product-info mt__15"><h3 class="product-title pr fs__14 mg__0 fwm">Product 1</h3><span class="price">€19.95 EUR</span></div></div>

preferences:
112.13 ms | 1492 KiB | 4 Q