Search code examples
phpsmarty

Formatting Integer Value Smarty


I am new in php and smarty formatting. I need to format an integer to take 5 places, for example to display 1 as 00001, 21 as 00021 and so on.

I tried string_format but instead of 00001 i was getting " 1". Can anybody help me?


Solution

  • string_format in Smarty uses sprintf

    So your code should look like this:

    {$number|string_format:"%'.05d"}