Home > Backend Development > PHP Tutorial > Sharing of PHP practical functions to remove redundant zeros, sharing of PHP practical functions_PHP tutorial

Sharing of PHP practical functions to remove redundant zeros, sharing of PHP practical functions_PHP tutorial

WBOY
Release: 2016-07-13 10:07:42
Original
1006 people have browsed it

Sharing of PHP practical functions to remove excess 0, Sharing of PHP practical functions

The code is very concise and simple, so there won’t be much nonsense.

Copy code The code is as follows:

/**
* Remove excess 0
​*/
function del0($s)
{
$s = trim(strval($s));
If (preg_match('#^-?d+?.0+$#', $s)) {
          return preg_replace('#^(-?d+?).0+$#','$1',$s);
}  
If (preg_match('#^-?d+?.[0-9]+?0+$#', $s)) {
          return preg_replace('#^(-?d+.[0-9]+?)0+$#','$1',$s);
}  
Return $s;
}

With free expansion, friends can do a lot of things. I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/954665.htmlTechArticlePHP utility function sharing removes redundant 0s. The php utility function sharing code is very concise and simple. What nonsense. Copy the code The code is as follows: /*** Remove redundant 0s*/ functio...
Related labels:
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