我正在尝试用数字中的逗号显示输出。我确信我是傻瓜,但我想不出如何让它发挥作用。我只想格式化价格的数字输出。任何帮助将不胜感激。
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>";
}
答案 0 :(得分:0)
直接来源: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