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"; $date = file_get_contents($url); $xml = simplexml_load_string($date); $json = json_encode($xml); $array = json_decode($json, true); $eur = 100; foreach($array as $v){ for ($x=0;$x<29;$x++) { $a = $v["Cube"]["Cube"]["$x"]["@attributes"]["rate"]; $b = $v["Cube"]["Cube"]["$x"]["@attributes"]["currency"]; $c = $eur*$a; $array1 = array( 1 => $a, 2 => $b ); arsort($array1); echo $b." - ".round($a, 2)." | ".round($c, 2)."\n"; } } //print_r($v);
Copy Clear