1

I have this question:
How can round two decimals place to next multiple to ten? Follow this example:

$number = 120.37
// I would like some functions or trick to transform this into 120.40

Is it possible in php?

3 Answers3

3

use this number format

number_format($number, 2, '.', '');

It will give output 120.40

Imtiaz Pabel
  • 5,307
  • 1
  • 19
  • 24
1

try this

number_format(round($number,1), 2, '.', '');

or just

round($number,1);

if you not need it with 2 decimals

aresklip
  • 86
  • 5
0

Try this

round($number * 10) / 10;
Diego Ferri
  • 2,657
  • 2
  • 27
  • 35