我试图让我的输出在数字中显示为逗号。我确信我很愚蠢,但我想不出如何让它发挥作用。我只是想格式化价格的数字输出。
echo "</tr></table><br>";
echo mysql_result($result,$i,"shortdescription")."<br><br>";
echo "<div style=\"background-color:#FDFFDB\">";
echo "<table border=1 cellpadding=5>";
echo "<tr>";
echo "<td class=txt width=200><b>Price low season</b><br><i>May 15th - Nov 30th</i></td>";
echo "<td class=txt width=200><b>Price high season</b><br><i>Dec 1st - May 14th</i></td>";
echo "<td class=txt width=200><b>Xmas, New Year &<br>Sailing regattas</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td class=txt>US$ ".mysql_result($result,$i,"pricelownight")." per night</td>";
echo "<td class=txt>US$ ".mysql_result($result,$i,"pricehighnight")." per night</td>";
if (mysql_result($result,$i,"pricespecial")){
echo "<td rowspan=2 class=txt>US$ ".mysql_result($result,$i,"pricespecial")." per week</td>";
} else {
echo "<td rowspan=2 class=txt>Price upon request</td>";
}
最佳答案
直接来自来源:http://www.php.net/manual/en/function.money-format.php
$number = 1234.56;
// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number) . "\n";
// USD 1,234.56
关于PHP/Mysql 数字格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23942353/