复制代码 代码如下:
/**
* 去除多余的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;
}
上一篇:cURL库如何在PHP项目中使用
下一篇:php中怎么设置定时执行任务