Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP: Getting 3.1 and not 3.10

Options
  • 13-01-2012 2:25am
    #1
    Registered Users Posts: 9,847 ✭✭✭


    Hiya,

    I have:

    $number= 1.55;

    $total = $number* 2
    echo $total

    It works but I am getting 3.1 and not 3.10

    Any ideas? :o


Comments

  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    number_format should do the trick.

    [php]
    $number= 1.55;
    $total = $number* 2

    echo number_format($total, 2);
    [/php]


  • Registered Users Posts: 9,847 ✭✭✭py2006


    Thanks for that! :)


Advertisement