Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

PHP: Getting 3.1 and not 3.10

  • 13-01-2012 02:25AM
    #1
    Registered Users, Registered Users 2 Posts: 9,845 ✭✭✭


    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, Registered Users 2 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, Registered Users 2 Posts: 9,845 ✭✭✭py2006


    Thanks for that! :)


Advertisement
Advertisement