In PHP, you can directly remove excess 0s through the "floatval()" function. This function can retain valid decimal points and can also remove excess 0s at the end. Its syntax is "float floatval(mixed $var) ".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php remove the 0 after the decimal point and keep non-zero
Use floatval($arg)
directly to convert, which can not only retain the valid decimal point, but also remove the extra 0 at the end, where arg is a variable.
floatval —Get the floating point value of the variable
Syntax
float floatval ( mixed $var )
Return the float value of the variable var.
Parameters
var var can be any scalar type. You cannot use floatval() with arrays or objects.
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of How to remove excess 0 in php. For more information, please follow other related articles on the PHP Chinese website!