You are here

function twig_number_format_filter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Extension/Core.php \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 vendor/twig/twig/lib/Twig/Extension/Core.php

File

vendor/twig/twig/lib/Twig/Extension/Core.php, line 586

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);
}