将浮点数 (1.2) 拆分为整数 (1) 和小数 (2)

Split float (1.2) into round number (1) and decimal (2)

我有一个花车:71.25

我希望小数在前端小很多,我能想到的唯一方法是 "split" 浮点数并执行如下操作:

<?php
$round = 71;
$decimals = 25;
?>

<p><?php echo $round . '.'; ?><small><?php echo $decimals; ?></small></p>

浮点数是从数学方程输出的,所以没有办法硬编码这种情况。

如何使用 PHP 实现此目的?如果有更好的方法,我愿意接受建议。

<?php

$float = 71.025;
$parts = explode('.', (string) $float);
print_r($parts);

结果数组

Array
(
    [0] => 71
    [1] => 025
)

参考: http://php.net/manual/en/function.explode.php