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
  • 94,024
  • 28
  • 166
  • 217
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
  • 28,495
  • 6
  • 61
  • 72
0

use below code you will get required one

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