Shorten long numbers to K/M/B?

前端 未结 10 2250
南方客
南方客 2020-11-27 03:39

I\'ve googled this a lot but i can\'t find any helpful functions based on my queries.

What i want is:

100 -> 100
1000 -> 1,000
142840 -> 142         


        
10条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 04:24

    CakePHP has a Number Helper with a method toReadableSize. You should be able to grok it and come up with something on your own. In it, $this->precision is basically like number_format(), and __n is a singular-or-plural function.

提交回复
热议问题