36

Im trying to format numbers with thousands separator Smarty.

So for example 1000 becomes 1,000.

Thanks.

babadbee
  • 863
  • 5
  • 14
  • 18

3 Answers3

69

or you can use php function inside smarty, this is for number_format, you can use other php function too :)

PHP : number_format($number, 2, '.', ',');

SMARTY :
{$number|number_format:2:".":","}
Puaka
  • 1,751
  • 13
  • 8
5

or just in smarty use {$var|number_format:0}

huncyrus
  • 648
  • 8
  • 18
0

Try to use string_format, it uses sprintf to format your string.

silent
  • 3,843
  • 23
  • 29