去除数字字符串小数点后多余的 0
parent
6cfd928845
commit
9d8d04d5b1
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue