Im trying to format numbers with thousands separator Smarty.
So for example 1000 becomes 1,000.
Thanks.
The number_format() function rounds numbers and adds commas as a thousands separator. You can pass it either one, two, or four parameters: number_format($n) rounds $n to the nearest whole number and adds commas in between thousands.
PHP | number_format() Function $number: It is required parameter which specified the number to be formatted. If no other parameters are set, the number will be formatted without decimals and with the comma (, ) as the thousands separator. $decimals: It is optional parameter and used to specifies decimals.
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:".":","}
or just in smarty use {$var|number_format:0}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With