Home > Backend Development > PHP Tutorial > Sharing of PHP practical functions to remove excess 0_PHP tutorial

Sharing of PHP practical functions to remove excess 0_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:07:52
Original
840 people have browsed it

Sharing of PHP practical functions to remove redundant 0

This series of articles is to share with you some common and practical PHP functions. This article is the first one. Let’s do a simple , remove excess 0

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

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;

 }

Friends can do a lot of things with free expansion. I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/954518.htmlTechArticleSharing of PHP practical functions to remove excess 0 This series of articles is to share with you some common and practical PHP functions. This article is the first. Let’s do a simple code to remove redundant 0s...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template