So I have generated a PHP script that, shows the currencies I want with rates from EU Central bank XML. But now I need to view the currencies in HTML so, that they can be easily copy pasted into a spreadsheet program without any needs to do additional actions.
Here's the page: LINK
and here's the code:
<?php
$xml = simplexml_load_file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
$want=array("USD","JPY","DKK","GBP","NOK","RUB","CAD");
foreach ($xml->children()->children() as $cubeTime) {
echo "Currencies date: " . $cubeTime['time'] . "<br />";
foreach ($cubeTime->children() as $cubeCurr) {
$array[(string)$cubeCurr['currency']] = $cubeCurr['rate'];;
}
}
?>
<table border="1">
<tr>
<th>Currency</th>
<th>Rate</th>
</tr>
<?
foreach ($want as $key => $curr){
echo "<tr><td>$curr</td><td>$array[$curr]</td></tr>";
}
?>
</table>
Originally asked by: Marko on Stack Overflow


Answers