获取小数位数 12345678910111213141516function getFloatLength($num){ $count = 0; if (!is_string($num)) { throw new \Exception('not string'); } $num = (string) $num; $temp = explode('.', $num); if (sizeof($temp) > 1) { $decimal = end($temp); $count = strlen($decimal); } return $count;}