$num = 12345.6789;
echo number_format($num, 2, '.', '') //12345.67
echo number_format($num, 3, ',', '.') //12.345,678
$num = 1000000;
$n1 = number_format($num); // 1,000,000
$n2 = number_format($num,2); // 1,000,000.00
$n3 = number_format($num,2,",","."); // 1.000.000,00
// Output
echo "$n1 <br> $n2 <br> $n3";
echo number_format(123456, 1, ",", " ");