function twig_number_format_filter

Number format filter.

All of the formatting options can be left null, in that case the defaults will be used. Supplying any of the parameters will override the defaults set in the environment object.

Parameters

Twig_Environment $env A Twig_Environment instance:

mixed $number A float/int/string of the number to format:

int $decimal The number of decimal points to display.:

string $decimalPoint The character(s) to use for the decimal point.:

string $thousandSep The character(s) to use for the thousands separator.:

Return value

string The formatted number

1 string reference to 'twig_number_format_filter'
Twig_Extension_Core::getFilters in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of filters to add to the existing list.

File

drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php, line 462

Code

function twig_number_format_filter(Twig_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null) {
  $defaults = $env
    ->getExtension('core')
    ->getNumberFormat();
  if (null === $decimal) {
    $decimal = $defaults[0];
  }
  if (null === $decimalPoint) {
    $decimalPoint = $defaults[1];
  }
  if (null === $thousandSep) {
    $thousandSep = $defaults[2];
  }
  return number_format((double) $number, $decimal, $decimalPoint, $thousandSep);
}