如何停止爆炸值?

$user->height = 5.10

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

Array ( [0] => 5 [1] => 1 )

How to do I get the second value to display as 10?

FYI print_r(explode('.',5.10))

outputs the same.

You are trying to explode a number.

The number is dropping the 0 as a number because it's irrelevant as a number. You'll have to convert your number to a string and then pad it if necessary.

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

print_r(explode('.',5.10))

The trailing zero is dropped before the value gets into explode. As long as you don't use a String, trailing zeroes will be omitted.

<?php

    $height = 5.10;

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

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

?>