PHP Country Code to HTML Currency Symbol List


/ Published in: PHP
Save to your folder(s)

This took me a while to create so thought I would share. Can be used with <a href="http://www.textfixer.com/resources/country-dropdowns.php">HTML dropdown lists</a>.


Copy this code and paste it in your HTML
  1. function country_currency( $amount = 0 ) {
  2. $bc = ''; // Set this to your country
  3. $currency_before = '';
  4. $currency_after = '';
  5.  
  6. if( $bc == 'GB' || $bc == 'IE' || $bc == 'CY' ) $currency_before = '&pound;';
  7. if( $bc == 'AT' || $bc == 'BE' || $bc == 'FI' || $bc == 'FR' ||
  8. $bc == 'DE' || $bc == 'GR' || $bc == 'GP' || $bc == 'IT' ||
  9. $bc == 'LU' || $bc == 'NL' || $bc == 'PT' || $bc == 'SI' ||
  10. $bc == 'ES') $currency_before = '&euro;';
  11. if( $bc == 'BR' ) $currency_before = 'R$';
  12. if( $bc == 'CN' || $bc == 'JP' ) $currency_before = '&yen;';
  13. if( $bc == 'CR' ) $currency_before = '&cent;';
  14. if( $bc == 'HR' ) $currency_after = ' kn';
  15. if( $bc == 'CZ' ) $currency_after = ' kc';
  16. if( $bc == 'DK' ) $currency_before = 'DKK ';
  17. if( $bc == 'EE' ) $currency_after = ' EEK';
  18. if( $bc == 'HK' ) $currency_before = 'HK$';
  19. if( $bc == 'HU' ) $currency_after = ' Ft';
  20. if( $bc == 'IS' || $bc == 'SE' ) $currency_after = ' kr';
  21. if( $bc == 'IN' ) $currency_before = 'Rs. ';
  22. if( $bc == 'ID' ) $currency_before = 'Rp. ';
  23. if( $bc == 'IL' ) $currency_after = ' NIS';
  24. if( $bc == 'LV' ) $currency_before = 'Ls ';
  25. if( $bc == 'LT' ) $currency_after = ' Lt';
  26. if( $bc == 'MY' ) $currency_before = 'RM';
  27. if( $bc == 'MT' ) $currency_before = 'Lm';
  28. if( $bc == 'NO' ) $currency_before = 'kr ';
  29. if( $bc == 'PH' ) $currency_before = 'PHP';
  30. if( $bc == 'PL' ) $currency_after = ' z';
  31. if( $bc == 'RO' ) $currency_after = ' lei';
  32. if( $bc == 'RU' ) $currency_before = 'RUB';
  33. if( $bc == 'SK' ) $currency_after = ' Sk';
  34. if( $bc == 'ZA' ) $currency_before = 'R ';
  35. if( $bc == 'KR' ) $currency_before = 'W';
  36. if( $bc == 'CH' ) $currency_before = 'SFr. ';
  37. if( $bc == 'SY' ) $currency_after = ' SYP';
  38. if( $bc == 'TH' ) $currency_after = ' Bt';
  39. if( $bc == 'TT' ) $currency_before = 'TT$';
  40. if( $bc == 'TR' ) $currency_after = ' TL';
  41. if( $bc == 'AE' ) $currency_before = 'Dhs. ';
  42. if( $bc == 'VE' ) $currency_before = 'Bs. ';
  43.  
  44. if( $currency_before == '' && $currency_after == '' ) $currency_before = '$';
  45.  
  46. return $currency_before . number_format( $amount, 2 ) . $currency_after;
  47. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.