6
0
Fork 0

去除数字字符串小数点后多余的 0

release
李静 2021-12-13 20:22:33 +08:00
parent 6cfd928845
commit 9d8d04d5b1
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
<?php
namespace App\Helpers;
class Numeric
{
/**
* 去除数字字符串小数点后多余的 0
*
* @param mixed $value
* @return string
*/
public static function trimZero($value)
{
if (is_numeric($value) && strpos($value, '.') !== false) {
return rtrim(rtrim($value, '0'), '.');
}
return $value;
}
}