Psyche Psyche - 1 year ago 72
PHP Question

How to make number_format() not to round numbers up

I have this number:

$double = '21.188624';

After using
number_format($double, 2, ',', ' ')
I get:


But what I want is:


Any ideea how can I make this work?

Thank you.

Answer Source

number_format will always do that, your only solution is to feed it something different:

$number = intval(($number*100))/100;


$number = floor(($number*100))/100;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download