diff --git a/functions/func.common.php b/functions/func.common.php index f5e4cf5..339e479 100644 --- a/functions/func.common.php +++ b/functions/func.common.php @@ -197,13 +197,20 @@ function rrmdir($dir, &$result = 0) * @param array $param значение и параметры * @return string отформатированное значение */ - function num_format($param) - { - if (is_array($param)) - return number_format($param['val'], $param['dec'], $param['after'], $param['thousand']); + function num_format($param) + { + if (is_array($param)) { + // Если параметр не передан, берем 0 + $val = (float)($param['val'] ?? 0); + $dec = (int)($param['dec'] ?? 0); // По умолчанию 0 знаков, если не указано иное + $after = (string)($param['after'] ?? '.'); + $thousand = (string)($param['thousand'] ?? ''); // По умолчанию без разделителя тысяч - return ''; - } + return number_format($val, $dec, $after, $thousand); + } + + return ''; + } /**