Home > Backend Development > PHP Problem > How to remove excess 0 in php

How to remove excess 0 in php

藏色散人
Release: 2023-03-08 16:24:01
Original
2545 people have browsed it

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) ".

How to remove excess 0 in php

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

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!

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