php number format with comma code example
Example 1: php number format
$num = 12345.6789;
echo number_format($num, 2, '.', '')
echo number_format($num, 3, ',', '.')
Example 2: php number format
$num = 123456.789;
echo number_format($num);
echo number_format($num, 4);
echo number_format($num, 4, '#');
echo number_format($num, 5, '#', 'T');
Example 3: format money with commas in php
<?php
function CurrencyFormat($number)
{
$decimalplaces = 2;
$decimalcharacter = '.';
$thousandseparater = ',';
return number_format($number,$decimalplaces,$decimalcharacter,$thousandseparater);
}
?>