Search code examples
phpnumber-formatting

How from number_format function I can remove the cents part in PHP


From this code:

$total = 750;
number_format($total, 2, ',', ' ').'<sup>$</sup>';

I get 750,00$.

How can I remove the ,00 part ?

Thanks.


Solution

  • To remove ,00 from the result.You must change your code to

    $total = 750;
    number_format($total, 0, ',', ' ').'<sup>$</sup>';