How to remove the excess zero by PHP
This article introduces the relevant knowledge of "how to remove excess zero by PHP". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The copy code is as follows:
/ * *
* remove excess 0
, /
Function del0 ($s)
{
$s = trim (strval ($s))
If (preg_match ('# ^ -?\ dcats?\ .0 + $#', $s)) {
Return preg_replace ('# ^ (-?\ dbath?)\ .0 + $#','$1 million, etc.)
}
If (preg_match ('# ^ -?\ dbath?\. [0-9] +?)) {
Return preg_replace ('# ^ (-?\ d +\. [0-9] +?)
}
Return $s
}
This is the end of the content of "how to get rid of excess zero in PHP". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!