Link to home
Start Free TrialLog in
Avatar of pkromer
pkromer

asked on

PHP currency formatting, remove comma

I have code that is returning a comma in a number higher than 1000 and I need to get rid of the comma.

This current code returns a number with a comma if the number is higher than 1000...

        $totals = array('subtotal' => number_format($subtotal,2),
                          'total'    => number_format($order['OrderTotal'],2));

This code does not return the comma but does add two extra zeroes after the decimal point, so it returns something like 1252.3400...

        $totals = array('subtotal' => ($subtotal),
                          'total'    => ($order['OrderTotal']));

So, that second code bit "fixes" the issue with the comma but now I need to get rid of the two extra zeros at the end returned by that second block of code.
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
$totals = array('subtotal' => ($subtotal, 2),
                          'total'    => ($order['OrderTotal']));
Avatar of pkromer
pkromer

ASKER

Thank you thank you.