更新时间:2023-02-21 16:22:34
The function you want is number_format
echo number_format(0.96, 2);
或者,如果缺少它,您可以检查并添加它.
Alternatively you can just check for and prepend it if it is missing.
if ($num[0] == '.')
$num = '0' . $num;
尽管这不会处理负数,但您需要为此编写更多的逻辑.
This wont handle negative numbers though, you would need to write a little more logic for that.