Strange problem with number_format()
Posted: Sun Jul 31, 2005 8:04 pm
I have the following piece of code for a shopping cart which grabs the total of all items in the cart.
For some reason the value of $totals['total'] is not formatted to 2 decimal points. Even though the values in $content['total_price'] are already formatted in this form. Even if i change the code to It has no effect and the amount is still not formatted correctly, anyone have any ideas? thanks.
Code: Select all
foreach ($contents as $content) $totals['total'] += $content['total_price'];Code: Select all
foreach ($contents as $content) $totals['total'] += number_format($content['total_price'], 2);