2016-02-29 15:59:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 00:18:10 +00:00
|
|
|
* @param int $amount
|
2016-02-29 15:59:36 +00:00
|
|
|
* @param string $currency_code
|
2016-03-05 00:18:10 +00:00
|
|
|
* @param int $decimals
|
2016-02-29 15:59:36 +00:00
|
|
|
* @param string $dec_point
|
|
|
|
|
* @param string $thousands_sep
|
2016-03-05 00:18:10 +00:00
|
|
|
*
|
2016-03-16 11:50:34 +00:00
|
|
|
* @return string
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
function money($amount, $currency_code = '', $decimals = 2, $dec_point = '.', $thousands_sep = ',')
|
|
|
|
|
{
|
|
|
|
|
switch ($currency_code) {
|
|
|
|
|
case 'USD':
|
|
|
|
|
case 'AUD':
|
|
|
|
|
case 'CAD':
|
2016-02-29 15:59:36 +00:00
|
|
|
$currency_symbol = '$';
|
|
|
|
|
break;
|
2016-03-05 00:18:10 +00:00
|
|
|
case 'EUR':
|
2016-02-29 15:59:36 +00:00
|
|
|
$currency_symbol = '€';
|
|
|
|
|
break;
|
2016-03-05 00:18:10 +00:00
|
|
|
case 'GBP':
|
2016-02-29 15:59:36 +00:00
|
|
|
$currency_symbol = '£';
|
|
|
|
|
break;
|
2016-03-05 00:18:10 +00:00
|
|
|
|
|
|
|
|
default:
|
2016-02-29 15:59:36 +00:00
|
|
|
$currency_symbol = '';
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
return $currency_symbol.number_format($amount, $decimals, $dec_point, $thousands_sep);
|
2016-03-05 00:18:10 +00:00
|
|
|
}
|