|
?currency= |
?format= |
| Value |
- AUD
- BRL
- CAD
- CHF
- CNY
- EUR
- GBP
- INR
- JPY
- MXN
- RUB
- USD
- ZAR
|
JSON |
| Description |
Extraction of Currency. |
Output in JSON. |
<?php
header('Content-Type: text/plain');
$content = file_get_contents('https://xmlcharts.com/cache/precious-metals.php?format=json');
if ($content === false) die('Something went wrong.');
foreach (json_decode($content, true) as $currency => $arr) {
foreach ($arr as $commodity => $price) {
print $commodity.' in '.$currency.' per gram: '.round($price, 2).PHP_EOL;
print $commodity.' in '.$currency.' per troy ounce: '.round($price * 31.1034768, 2).PHP_EOL.PHP_EOL;
}
}
?>