This may be a easy question to answer but I am a bit stumped and I have not studied Smarty long enough to figure it out.
I need to display numbers in a 3 digit format, ie:
8 = 008
18 = 018
118 = 118
To add some context, basically I am trying to edit a Prestashop template (never touched smarty before this). Currently the price is displayed as 1.223.014 and I would like to separate the last three digits so that I can format it differently from the first part of the price. Thus I would be able to do something like
<span class="abc">1.223</span>.<span class="xyz">014</span>
Not sure if there is a easier way to do this but basically I am currently dividing the current price by 1000 (to eliminate the last 3 digits) and now I am stumped on how to get the last 3 digits (works fine if the last three digits are above 99)
Your help is appreciated.
Thanks
Solution for your example
{"%03d"|sprintf:8}Possible solution if you want the last 3 digits in any case
{'1.223.014'|substr:-3}html:
Note: This will not work if the number length is lower than 4
If you wanna check if there are dots inside the number, you can do this
Tested with smarty 3.