-1

例如,我有一个号码123457。我要这个:1234.57

我已经尝试过format_numberround()等等,但它不起作用。

我怎样才能做到这一点?

4

2 回答 2

9

If you want to make sure you don't get weird results from a bare division like $number / 100, you could use sprintf() to format it:

echo sprintf('%.2f', $number / 100);
于 2013-07-05T09:29:38.817 回答
3

您只需要将数字除以 100:

$num = 123457;
$dec = $num / 100;

echo $dec; // 1234.57

这是一个演示

于 2013-07-05T09:28:58.977 回答