ADVERTISEMENT


Breaking News

Recent Posts

Sunday, September 13, 2015

Return html entity of currency code in php

Some time you need to get html entity of currency code so 
I would like to share with you a smart method you just need to add below method in your project, 

It includes major famous country code or you can add it more hope 
so that will work fine for you J



 /* get html entity of currency symboles */  
 function GetCurrencySymbol($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" => "&#36" , //Hong Kong Dollar  
   "HUF" => "Ft" , //Hungarian Forint  
   "ILS" => "₪" , //Israeli New Sheqel  
   "INR" => "₹" //Indian Rupee  
   "JPY" => "¥" , //Japanese Yen   
   "MYR" => "RM" , //Malaysian Ringgit   
   "MXN" => "&#36" , //Mexican Peso  
   "NOK" => "kr" , //Norwegian Krone  
   "NZD" => "&#36" , //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

 GetCurrencySymbol(“CAD”);  

No comments:

Post a Comment

Designed By Published.. Blogger Templates