How to remove 0 after decimal point in php

藏色散人
Release: 2023-03-04 09:30:02
Original
6039 people have browsed it

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.

How to remove 0 after decimal point in php

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 )
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template