Results 1 to 4 of 4

Thread: Adding a zero after computation

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    17

    Question Adding a zero after computation

    Hi Everyone I've come across a little problem
    I've been working on a simple shopping cart
    and so far so good but after computing the
    totals they do not appear as floats with 2 decimal
    places (£2.50 is £2.5)..how can i avoid this problem.
    Please help

    Here's my code:
    Code:
    $total2=$light_packages * $price2 * $years_light;

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Adding a zero after computation

    add this after that line:

    PHP Code:
    $total2 number_format($total22); 
    EDIT:
    you may also want to look at this http://us3.php.net/manual/en/function.money-format.php
    My usual boring signature: Something

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    17

    Re: Adding a zero after computation

    thankyou that worked fine ...thanks for the info too

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Adding a zero after computation

    your welcome

    please set this post as resolved, and give reputation accordingly
    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width