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.
http://www.bkjia.com/PHPjc/954665.htmlwww.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...
Statement: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