如何在 PHP 中将数字转换为特定格式


How to convert a number to a specific format in PHP?

我想在 PHP 中以 10,00,000 的格式显示一个数字 1000000

进行此转换的 PHP 函数是什么?

使用number_format函数

<?php
echo number_format(100000); // prints 1,000,000
?>

如果您需要显示格式为十万和千万的值:

$amount = 1000000000;
setlocale(LC_MONETARY, 'en_IN');
$amount = money_format('%!i', $amount);
echo $amount;

应该给100,00,00,000而不是1,000,000,000