Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to remove excess zero after decimal point in php

Shulou Source: shulou.com Published: 2022-05-31 11:00:59 10月26日 Update

This article mainly explains how php removes excess zeros after the decimal point. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how php removes excess zeros after the decimal point.

1. Use "decimal + 0".

2. Use "floatval".

3. Use "rtrim (rtrim (decimal,'0'),'."

4. Use "preg_replace ('/ [.] $/', preg_replace ('/ 0 percent).

The regular expression states: / 0 echo preg_replace / remove the extra 0 / [.] $/ at the end. Echo preg_replace ('/ [.] $/',', preg_replace ('/ 0 million dollar,', '100.00'). "; echo preg_replace (' / [.] $/','', preg_replace ('/ 0 million))." Echo preg_replace ('/ [.] $/', preg_replace ('/ 0 percent),', '100.010203000')). "? > at this point, I believe you have a deeper understanding of" php how to remove excess zero after the decimal point ", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Decimal decimal content end learning practical deeper interested practical practical easy to operate method more friends regular website expression channel query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi Shulou Information macOS Shulou Tech Info