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
😕

    use the pringf() function

    $money= 31.9 ;
    printf("£= %.2f",$money);
    

      You could try:

      $newtotal=round($total, 2);

        All that jshea wants is no round() function,
        he would only type the number in 2 decimal after comma

          You were right. It is early and I misinterperited the question.

          Thanks for clarifying.

            Write a Reply...