PHP format currency


SUBMITTED BY: Guest

DATE: Oct. 23, 2013, 9:09 a.m.

FORMAT: PHP

SIZE: 671 Bytes

HITS: 961

  1. <?php
  2. function formatCurrencySign($price, $currency, $separator = "")
  3. {
  4. if (!in_array($currency, array('USD', 'GBP', 'EUR')))
  5. {
  6. return $price . $separator . $currency;
  7. }
  8. switch ($currency)
  9. {
  10. case 'USD':
  11. $format = "$" . $separator . $price;
  12. break;
  13. case 'GBP':
  14. $format = "£" . $separator . $price;
  15. break;
  16. case 'EUR':
  17. $format = "€" . $separator . $price;
  18. break;
  19. }
  20. return $format;
  21. }
  22. ?>

comments powered by Disqus