取四捨五入
語法 : double round(double val [ , int precision] );
EX:
< ?
$NUM=3.14159;
round($NUM); // NUM=3
round($NUM,2); // NUM=3.14
round($NUM,3); // NUM=3.142
?>
適用於PHP3~4
官網上面的例子:
float round ( float $val [, int $precision ] )
< ?php
echoround(3.4);//3
echoround(3.5);//4
echoround(3.6);//4
echoround(3.6,0);//4
echoround(1.95583,2);//1.96
echoround(1241757,-3);//1242000
echoround(5.045,2);//5.05
echoround(5.055,2);//5.06
?>
echoround(3.4);//3
echoround(3.5);//4
echoround(3.6);//4
echoround(3.6,0);//4
echoround(1.95583,2);//1.96
echoround(1241757,-3);//1242000
echoround(5.045,2);//5.05
echoround(5.055,2);//5.06
?>
適用於PHP4~5