Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@goldsky
Last active December 13, 2015 19:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldsky/4966067 to your computer and use it in GitHub Desktop.
Save goldsky/4966067 to your computer and use it in GitHub Desktop.
ISO-4217 Currency Codes in a PHP array
<?php
header('Content-Type: text/html; charset=utf-8');
/**
* Download the currecy data from the link below, and place it along side this file
* @link http://www.currency-iso.org/en/home/tables/table-a1.html Current currency & funds code list
*/
$xml = file_get_contents( dirname(__FILE__) . '/dl_iso_table_a1.xml');
$currencyArray = json_decode(json_encode((array) simplexml_load_string($xml)), 1);
/**
* If you want to see the results, uncomment the following codes
*/
//echo '<pre>';
//echo 'return array(' . "<br />";
//foreach ($currencyArray['ISO_CURRENCY'] as $k => $v) {
// echo "\t" . 'array(' . "<br />";
// foreach ($v as $key => $value) {
// $hasValue = !empty($value) ? ' => \'' . addslashes($value) . '\'': null;
// echo "\t\t" . '\'' . $key . '\'' . $hasValue . ',' . "<br />";
// }
// echo "\t" . '),' . "<br />";
//}
//echo ');';
//echo '</pre>';
return $currencyArray['ISO_CURRENCY'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment