$number = 1234567.89;
$formatted_number = number_format($number);
echo $formatted_number; // 輸出:1,234,567.89
$number = 1234.56789;
$formatted_number = number_format($number, 2);
echo $formatted_number; // 輸出:1,234.57
$number = 1234.56789;
$formatted_number = number_format($number, 2, ',', '.');
echo $formatted_number; // 輸出:1.234,57
$number = -1234.56789;
$formatted_number = number_format($number, 2);
echo $formatted_number; // 輸出:-1,234.57
$number = 1234567.89;
$formatted_number = number_format($number, 2, '.', '');
echo $formatted_number; // 輸出:1234567.89
$number = 1.2e6;
$formatted_number = number_format($number, 0);
echo $formatted_number; // 輸出:1,200,000
這些是一些常見的使用技巧,根據具體需求,可以靈活運用number_format函數來格式化數字。