mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Fixed Currency Parser Filter
This commit is contained in:
parent
9abd6bb2cf
commit
9171921e54
@ -256,16 +256,18 @@ class Filters
|
||||
* @param $value
|
||||
* @param string $currency
|
||||
* @param string|null $locale
|
||||
* @param integer $fraction
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function local_currency($value, string $currency, string $locale = null): string
|
||||
public static function local_currency($value, string $currency, string $locale = null, $fraction = null): string
|
||||
{
|
||||
helper('number');
|
||||
|
||||
$options = [
|
||||
'type' => NumberFormatter::CURRENCY,
|
||||
'currency' => $currency,
|
||||
'fraction' => $fraction,
|
||||
];
|
||||
|
||||
return format_number($value, 2, $locale, $options);
|
||||
|
@ -403,7 +403,7 @@ EOF;
|
||||
'mynum' => 1234567.891234567890000,
|
||||
];
|
||||
|
||||
$template = '{ mynum|local_currency(EUR,de_DE) }';
|
||||
$template = '{ mynum|local_currency(EUR,de_DE,2) }';
|
||||
|
||||
$parser->setData($data);
|
||||
$this->assertEquals('1.234.567,89 €', $parser->renderString($template));
|
||||
|
Loading…
x
Reference in New Issue
Block a user