luki180 luki180 - 22 days ago 7
PHP Question

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?

Answer

string_format in Smarty uses sprintf

So your code should look like this:

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