Hi,
Quick question. What is the difference:
PHP Code:Total: $<?php echo number_format($totalCost, 2, ".", ","); ?>Matt.PHP Code:Total: $<?php echo $totalCost;?>
| SitePoint Sponsor |


Hi,
Quick question. What is the difference:
PHP Code:Total: $<?php echo number_format($totalCost, 2, ".", ","); ?>Matt.PHP Code:Total: $<?php echo $totalCost;?>
Well the number format. Duh.
Basically the additional is just to guarantee the output is formated in the right way (in this case, money).
Most likely, this is because $totalcost is a calculated number (like 56000.0), and it needs to be displayed human-comfort-readable (56,000.00). Note the extra 0 and thousands seperation.
Bookmarks