Domain Manage

PHP Number Formats

Discussion in 'Scripts and Coding' started by admin, Dec 6, 2008.

Thread Status:
Not open for further replies.
  1. admin Spain

    admin Administrator Staff Member

    Joined:
    Jun 2004
    Posts:
    10,084
    Likes Received:
    115
    I am trying to format a number being read for a MySQL DB into a PHP page.

    My field in the DB is set as decimal (50,0)
    My code in my PHP is:
    PHP:
    <td class="cat">£{$data|number_format}</td>
    The output is 4,500.00

    How do I change this to drop the decimals i.e. 4,500 ??

    Thanks

    Admin
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
     
  3. Jeewhizz

    Jeewhizz Well-Known Member

    Joined:
    May 2006
    Posts:
    1,177
    Likes Received:
    18
    PHP:
    {$data|number_format}
    That isn't strictly PHP. It's part of the template parser. However, not sure which one. Could be smarty, which if it is try this:

    PHP:
    {$data|number_format:0}
     
  4. admin Spain

    admin Administrator Staff Member

    Joined:
    Jun 2004
    Posts:
    10,084
    Likes Received:
    115
    Yes it's Smarty and it works perfectly.

    Thanks a lot, I've been fiddling with that for ages!

    Admin
     
  5. Jeewhizz

    Jeewhizz Well-Known Member

    Joined:
    May 2006
    Posts:
    1,177
    Likes Received:
    18
    No problems. Smarty is v good - we use it for quite a few clients.

    Smarty might be worth reading :)
     
  6. admin Spain

    admin Administrator Staff Member

    Joined:
    Jun 2004
    Posts:
    10,084
    Likes Received:
    115
    Yeah I'm still in the learning curve but results look good.

    thanks for the help.

    Admin
     
Thread Status:
Not open for further replies.

Share This Page