不常用,所以整理在這里,分享給同行使用
方法一:取尾數法
public function NumToStr($num) { if (stripos($num, 'e') === false) return $num; $num = trim(preg_replace('/[=\'"]/', '', $num, 1), '"'); //出現科學計數法,還原成字符串 $result = ""; while ($num > 0) { $v = $num - floor($num / 10) * 10; $num = floor($num / 10); $result = $v . $result; } return $result; }
方法二:數字規律法
function sctonum($num){ if(false !== stripos($num, "e")){ $a = explode("e",strtolower($num)); return bcmul($a[0], bcpow(10, $a[1])); } }
