1
$a =99.99999;
echo $f = sprintf ("%.2f", $a);

output value is 100.00

But i need 99.99

can any one help this please

Baba
  • 92,047
  • 28
  • 163
  • 215
user2235324
  • 13
  • 1
  • 2

2 Answers2

3

http://3v4l.org/LdHLA

echo intval((99.99999*100))/100;

Taken from here:

How to make number_format() not to round numbers up

Community
  • 1
  • 1
jszobody
  • 27,683
  • 6
  • 59
  • 69
-1

use below code you will get required one

echo number_format($a,2);
Praveen kalal
  • 2,088
  • 4
  • 19
  • 33