Skip to content

Instantly share code, notes, and snippets.

@rajaishtiaq6
Created November 15, 2022 18:46
Show Gist options
  • Save rajaishtiaq6/9f94484d4f2da00d7894f138740d0809 to your computer and use it in GitHub Desktop.
Save rajaishtiaq6/9f94484d4f2da00d7894f138740d0809 to your computer and use it in GitHub Desktop.
get currency symbol by currency code in php
function get_currency_symbol($currency = '')
{
$symbols = array(
'AED' => 'د.إ', // ?
'AFN' => 'Af',
'ALL' => 'Lek',
'AMD' => '֏',
'ANG' => 'ƒ',
'AOA' => 'Kz', // ?
'ARS' => '$',
'AUD' => '$',
'AWG' => 'ƒ',
'AZN' => 'ман',
'BAM' => 'KM',
'BBD' => '$',
'BDT' => '৳', // ?
'BGN' => 'лв',
'BHD' => '.د.ب', // ?
'BIF' => 'FBu', // ?
'BMD' => '$',
'BND' => '$',
'BOB' => '$b',
'BRL' => 'R$',
'BSD' => '$',
'BTC' => '฿',
'BTN' => 'Nu.', // ?
'BWP' => 'P',
'BYR' => 'p.',
'BYN' => 'Br',
'BZD' => 'BZ$',
'CAD' => '$',
'CDF' => 'FC',
'CHF' => 'CHF',
'CLF' => '', // ?
'CLP' => '$',
'CNY' => '¥',
'COP' => '$',
'CRC' => '₡',
'CUC' => '⃌',
'CUP' => '⃌',
'CVE' => '$', // ?
'CZK' => 'Kč',
'DJF' => 'Fdj', // ?
'DKK' => 'kr',
'DOP' => 'RD$',
'DZD' => 'دج', // ?
'EGP' => '£',
'ERN' => 'Nfk', // ?
'ETB' => 'Br',
'EUR' => '€',
'FJD' => '$',
'FKP' => '£',
'GBP' => '£',
'GEL' => 'ლ', // ?
'GGP' => '£',
'GHS' => '¢',
'GIP' => '£',
'GMD' => 'D', // ?
'GNF' => 'FG', // ?
'GTQ' => 'Q',
'GYD' => '$',
'HKD' => '$',
'HNL' => 'L',
'HRK' => 'kn',
'HTG' => 'G', // ?
'PKE' => '$',
'HUF' => 'Ft',
'IDR' => 'Rp',
'ILS' => '₪',
'IMP' => '£',
'INR' => '₹',
'IQD' => 'ع.د', // ?
'IRR' => '﷼',
'IRT' => '﷼',
'ISK' => 'kr',
'JEP' => '£',
'JMD' => 'J$',
'JOD' => 'JD', // ?
'JPY' => '¥',
'KES' => 'KSh', // ?
'KGS' => 'лв',
'KHR' => '៛',
'KMF' => 'CF', // ?
'KPW' => '₩',
'KRW' => '₩',
'KWD' => 'د.ك', // ?
'KYD' => '$',
'KZT' => 'лв',
'LAK' => '₭',
'LBP' => '£',
'LKR' => '₨',
'LRD' => '$',
'LSL' => 'L', // ?
'LTL' => 'Lt',
'LVL' => 'Ls',
'LYD' => 'ل.د', // ?
'MAD' => 'د.م.', //?
'MDL' => 'L',
'MGA' => 'Ar', // ?
'MKD' => 'ден',
'MMK' => 'K',
'MNT' => '₮',
'MOP' => 'MOP$', // ?
'MRO' => 'UM', // ?
'MUR' => '₨', // ?
'MVR' => '.ރ', // ?
'MWK' => 'MK',
'MXN' => '$',
'MYR' => 'RM',
'MZN' => 'MT',
'NAD' => '$',
'NGN' => '₦',
'NIO' => 'C$',
'NOK' => 'kr',
'NPR' => '₨',
'NZD' => '$',
'OMR' => '﷼',
'PAB' => 'B/.',
'PEN' => 'S/.',
'PGK' => 'K', // ?
'PHP' => '₱',
'PKR' => '₨',
'PLN' => 'zł',
'PYG' => 'Gs',
'QAR' => '﷼',
'RON' => 'lei',
'RSD' => 'Дин.',
'RUB' => 'руб',
'RWF' => 'ر.س',
'SAR' => '﷼',
'SBD' => '$',
'SCR' => '₨',
'SDG' => '£', // ?
'SEK' => 'kr',
'SGD' => '$',
'SHP' => '£',
'SLL' => 'Le', // ?
'SOS' => 'S',
'SPL' => '£',
'SRD' => '$',
'STD' => 'Db', // ?
'SVC' => '$',
'SYP' => '£',
'SZL' => 'L', // ?
'THB' => '฿',
'TJS' => 'TJS', // ? TJS (guess)
'TMT' => 'm',
'TND' => 'د.ت',
'TOP' => 'T$',
'TRY' => '₤', // New Turkey Lira (old symbol used)
'TTD' => '$',
'TVD' => '$',
'TWD' => 'NT$',
'TZS' => '',
'UAH' => '₴',
'UGX' => 'USh',
'USD' => '$',
'UYU' => '$U',
'UZS' => 'лв',
'VEF' => 'Bs',
'VND' => '₫',
'VUV' => 'VT',
'WST' => 'WS$',
'XAF' => 'FCFA',
'XCD' => '$',
'XDR' => '',
'XOF' => '',
'XPF' => 'F',
'ZAR' => 'R',
'ZMW' => 'ZK',
);
if (isset($symbols[$currency])) {
return $symbols[$currency];
}
return $currency;
}
echo get_currency_symbol('USD');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment