对大于一万的数字保留前两位其余补0 // 补0function rounding($num){ $count = strlen($num); $firstNum = intval(substr($num, 0, 1)); $secondNum = intval(substr($num, 1, 1)); $thirdNum = intval(substr($num, 2, 1)); $restNum = $co
// 补0 function rounding($num) { $count = strlen($num); $firstNum = intval(substr($num, 0, 1)); $secondNum = intval(substr($num, 1, 1)); $thirdNum = intval(substr($num, 2, 1)); $restNum = $count-1; if ($count >= 5) { if ($thirdNum >= 5) { if ($secondNum == 9) { $firstNum += 1; $secondNum = 0; $thirdNum = 0; $num = $firstNum*pow(10, $restNum); } else { $secondNum += 1; $thirdNum = 0; $num = ($firstNum*10+$secondNum)*pow(10, $count-2); // 78600 79000 } } } return $num; } // 显示中文单位 function downnumConversion($downnum) { $downnum = rounding($downnum); $count = strlen($downnum); if ($count >= 5 && $count < 9) { $previousNum = substr($downnum, 0, $count-4); $downnum = $previousNum.'万'; } elseif ($count >= 9) { $previousNum = substr($downnum, 0, $count-8); $nextNum = substr($downnum, 1, $count-8); if ($nextNum) { $downnum = $previousNum.'.'.$nextNum.'亿'; } else { $downnum = $previousNum.'亿'; } } return $downnum; }