String format
string_format — This is a way to format strings, such as decimal numbers and such. Use the syntax for sprintf() for the formatting.
{$myVar|string_format:"%d"}
Parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
| 1 | string | Yes | This is what format to use. (sprintf) |
Examples:
<?php
$tplix->assign('number', 23.5787446);
Where the template is:
{$number}
{$number|string_format:"%.2f"}
{$number|string_format:"%d"}
Output:
23.5787446
23.58
23