如何停止对值进行四舍五入?

How can I stop explode rounding a value?

$用户->身高=5.10

print_r(explode('.',$user->height))

数组 ( [0] => 5 [1] => 1 )

如何让第二个值显示为 10?

仅供参考 print_r(explode('.',5.10))

输出相同。

您正在尝试爆号。

该数字正在删除 0 作为数字,因为它与数字无关。您必须将您的号码转换为字符串,然后在必要时填充它。

$number = 5.10;
$string_version = number_format((float)$number, 2, '.', '');
print_r(explode('.', $string_version));

print_r(explode('.',5.10))

尾随零在值进入爆炸之前被删除。只要您不使用字符串,就会省略尾随零。

<?php

    $height = 5.10;

    header( "Content-Type: text/plain" );

    // Outputs: height = 5.1
    echo( "height = " . $height . "\r\n" );
    print_r( explode( ".", $height ) );

?>