Skip to content

Instantly share code, notes, and snippets.

@shyamsalimkumar
Last active December 18, 2015 08:18
Show Gist options
  • Save shyamsalimkumar/5752558 to your computer and use it in GitHub Desktop.
Save shyamsalimkumar/5752558 to your computer and use it in GitHub Desktop.
PHP - Format currency
function formatCurrencySign($price, $currency, $separator = "")
{
if (!in_array($currency, array('USD', 'GBP', 'EUR')))
{
return $price . $separator . $currency;
}
switch ($currency)
{
case 'USD':
$format = "$" . $separator . $price;
break;
case 'GBP':
$format = "£" . $separator . $price;
break;
case 'EUR':
$format = "€" . $separator . $price;
break;
}
return $format;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment