Return Currency Symbols using PHP
I needed a PHP function that returns HTML Entity of currency codes, so I have written this small function with list of major currency symbols of the world, I hope this will be useful.
PHP
1234567891011121314151617181920212223242526272829303132333435
/* get currency symboles */
function get_currency_symbol($cc = 'USD')
{
$cc = strtoupper($cc);
$currency = array(
"USD" => "$" , //U.S. Dollar
"AUD" => "$" , //Australian Dollar
"BRL" => "R$" , //Brazilian Real
"CAD" => "C$" , //Canadian Dollar
"CZK" => "Kč" , //Czech Koruna
"DKK" => "kr" , //Danish Krone
"EUR" => "€" , //Euro
"HKD" => "$" , //Hong Kong Dollar
"HUF" => "Ft" , //Hungarian Forint
"ILS" => "₪" , //Israeli New Sheqel
"INR" => "₹", //Indian Rupee
"JPY" => "¥" , //Japanese Yen
"MYR" => "RM" , //Malaysian Ringgit
"MXN" => "$" , //Mexican Peso
"NOK" => "kr" , //Norwegian Krone
"NZD" => "$" , //New Zealand Dollar
"PHP" => "₱" , //Philippine Peso
"PLN" => "zł" ,//Polish Zloty
"GBP" => "£" , //Pound Sterling
"SEK" => "kr" , //Swedish Krona
"CHF" => "Fr" , //Swiss Franc
"TWD" => "$" , //Taiwan New Dollar
"THB" => "฿" , //Thai Baht
"TRY" => "₺" //Turkish Lira
);
if(array_key_exists($cc, $currency)){
return $currency[$cc];
}
}
Usage
PHP
12
get_currency_symbol('GBP'); //returns Pound