1. public function numberFilter($number)
    2. {
    3. if ($number <= 1000) {
    4. return $number;
    5. }
    6. $currentValue = $currentUnit = null;
    7. $unitExps = array('千' => 3, '万' => 4, '亿' => 8);
    8. foreach ($unitExps as $unit => $exp) {
    9. $divisor = pow(10, $exp);
    10. $currentUnit = $unit;
    11. $currentValue = $number / $divisor;
    12. if ($currentValue < 10) {
    13. break;
    14. }
    15. }
    16. return sprintf('%.0f', $currentValue).$currentUnit;
    17. }