Nice answer Kyle. A few remarks though: You should use if(abs($number) < ($divisor * 1000)) {, otherwise negative numbers will never get shorten. Also, it might be a good idea to instantiate $divisor and $shortand, just to make sure there's no exception when a user might pass an empty $divisors. Thanks!
– Luís CruzAug 24 '16 at 10:30

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.