php中的2个十进制数字?

zor*_*oro 0 php

例如:
(a)123 /(b)1000 =(c)0,123
echo c必须为0,12

如何做到这一点?

Dan*_*erg 6

使用round(),sprintf()number_format().

例子:

<?php
$res = 123/1000;
printf('%.2f', $res);
echo round($res, 2);
echo number_format($res, 2);
?>
Run Code Online (Sandbox Code Playgroud)