Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8459271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:17:27+00:00 2026-06-10T13:17:27+00:00

This may be a easy question to answer but I am a bit stumped

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:17:28+00:00Added an answer on June 10, 2026 at 1:17 pm

    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:

    <span class="abc">{'1.223.014'|substr:0:-4}</span>.<span class="xyz">{'1.223.014'|substr:-3}</span>
    

    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

    {if '1.223.014'|substr_count:'.' > 0}
    ..dots inside..
    {else}
    ..no dots inside..
    {/if}
    

    Tested with smarty 3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be an easy question to answer but I could not find a
Well this may be a very easy Question but I'm not getting the answer
This may seem an easy question, but not to me, also a search has
I have a feeling I may already know the answer to this question, but
This question may be easy and the answer obvious, but I can't seem to
This may be an extremely easy question but I can't get my head around
This may be an easy answer but I've been staring at it for too
This may be a stupid question but I have a code with the following
This may be a simple question but I can;t find the answer anywhere. Here
this may be a easy question, but I really need a light to go

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.