Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $url = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); if ($response) { $xml = simplexml_load_string($response); if ($xml !== false) { $currencies = $xml->xpath('/gesmes:Envelope//Cube[@currency]'); foreach ($currencies as $currency) { $currencyCode = (string)$currency['currency']; $exchangeRate = (float)$currency['rate']; echo "Код валюты: $currencyCode, Курс: $exchangeRate\n"; } } else { echo "error2\n"; } } else { echo "error1\n"; }
Copy Clear