Home > Article > Backend Development > How to remove 0 after decimal point in php
In PHP, you can directly use the "floatval" function to remove 0 after the decimal point. The syntax of the floatval function is "float floatval (mixed $var)". Using this function for conversion can not only retain valid decimal points, but also Remove the extra 0 at the end.
Recommendation: "PHP Video Tutorial"
You can directly use floatval($arg) to convert, either Keep valid decimal points, and you can also remove the extra 0 at the end where arg is a variable.
floatval gets the floating point value of the variable
Syntax
float floatval ( mixed $var )
Returns the float value of the variable var.
Parameters
var var can be any scalar type. You cannot use floatval() with arrays or objects.
Return value: The floating point value of the var variable.
PHP version: PHP 4 >= 4.2.0, PHP 5, PHP 7
The above is the detailed content of How to remove 0 after decimal point in php. For more information, please follow other related articles on the PHP Chinese website!