2010-04-05 80 views

回答

2
number_format($number, 2, '.', '') 
+0

我只是看着那个男人(http://php.net/manual/en/function.number-format.php)......我认为','''最后是千万位以上的逗号不要显示出来? – aslum 2010-04-05 19:10:14

+0

是的,这是正确的。 – GSto 2010-04-05 20:51:26

1

的正则表达式来救援:

if (preg_match('/^\d+\.\d{2}$/', $number[$i])) { 
    etc... 
} 
当然

,现在正则表达式都参与其中,你有two problems,如那句老话。

1
$number[$i] = round((float)$number[$i], 2); 
相关问题