Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
/**
3
 * Smarty plugin
4
 *
5
 * @package    Smarty
6
 * @subpackage PluginsModifier
7
 */
8
 
9
/**
10
 * Smarty number_format modifier plugin
11
 * Type:     modifier
12
 * Name:     number_format
13
 * Purpose:  Format a number with grouped thousands
14
 *
15
 * @param float|null  $num
16
 * @param int         $decimals
17
 * @param string|null $decimal_separator
18
 * @param string|null $thousands_separator
19
 *
20
 * @return string
21
 */
22
function smarty_modifier_number_format(?float $num, int $decimals = 0, ?string $decimal_separator = ".", ?string $thousands_separator = ",")
23
{
24
    // provide $num default to prevent deprecation errors in PHP >=8.1
25
    return number_format($num ?? 0.0, $decimals, $decimal_separator, $thousands_separator);
26
}