我想把逗号放在数字中 输出是以json数组
编码的[{"total2":"7619627.0000"}]
我想更改此格式的数字
[{"total2":"7,619,627"}]
继承人的PHP代码
$sql2 = "SELECT SUM(NettoPrice) AS total2 FROM Sales WHERE OrderType = 8";
$result2 = $conn->query($sql2);
// output data of each row
while($row[] = $result2->fetch_assoc()) {
$json = json_encode($row);
}
echo $json;
$conn->close();
?>
答案 0 :(得分:0)
使用number_format();
$row[count($row)-1]['total2'] = number_format($row[count($row)-1]['total2']);
$json = json_encode($row);
答案 1 :(得分:0)
使用MYSQL 5.5:
SELECT FORMAT(SUM(NettoPrice),0) AS total2;
使用PHP
number_format('7619627.0000',0);