Movatterモバイル変換


[0]ホーム

URL:


Twig

Twig

The flexible, fast, and secure
template engine for PHP

a Symfony Product
DocsFiltersround
Docs for Twig version 3.x
Switch to another version:1.x,2.x

Questions & Feedback

Found a typo or an error?
Want to improve this document?Edit it.

Need support or have a technical question?
Ask support onStack Overflow.

License

Twigdocumentation is licensed under the new BSDlicense.

round

Theround filter rounds a number to a given precision:

12345
{{ 42.55|round }}{# outputs 43 #}{{ 42.55|round(1, 'floor') }}{# outputs 42.5 #}

Theround filter takes two optional arguments; the first one specifies theprecision (default is0) and the second the rounding method (default iscommon):

  • common rounds either up or down (rounds the value up to precision decimalplaces away from zero, when it is half way there -- making 1.5 into 2 and-1.5 into -2);
  • ceil always rounds up;
  • floor always rounds down.

Note

The// operator is equivalent to|round(0, 'floor').

Arguments

  • precision: The rounding precision
  • method: The rounding method
« reverse| shuffle »

[8]ページ先頭

©2009-2025 Movatter.jp