if i want to display a float variable to 2 decimall places, who do i do it

problem is that i am displaying a monitory value but if it is only 1 decimal place is just shows the 1 decimal place from a variable called total, ie

£31.9

which should be £31.90

please help, had a look at the manual quickly but to no avail.

Many Thanks

Sunit

    $FormattedCurrency = sprintf('%01.2f', $currency); // formats var

    OR

    printf('%01.2f', $currency); // prints formatted var

      This is what I use.

      hope it helps

      /s

      $total= (number_format($total,2));
      
        Write a Reply...