Kак укоротить большие числа в php?
<?php
function shortenNumber($number)
{
	if ($number != 0 && $number % 1000 == 0) {
		return $number/1000 . 'K';
	}
	return $number;
}

echo shortenNumber('1000'); // 1K
echo shortenNumber(123); // 123
echo shortenNumber(0); // 0
echo shortenNumber(-10000); // -10K
Более краткий вариант с регуляркой:<?php
function shortenNumber($number)
{
	return preg_replace('/000$/', 'K', $number);
}
Универсальная функция: function number_format_short($n, $precision = 1)
{
    if ($n < 900) {
        // 0 - 900
        $n_format = number_format($n, $precision);
        $suffix = '';
    } else
        if ($n < 900000) {
            // 0.9k-850k
            $n_format = number_format($n / 1000, $precision);
            $suffix = 'K';
        } else
            if ($n < 900000000) {
                // 0.9m-850m
                $n_format = number_format($n / 1000000, $precision);
                $suffix = 'M';
            } else
                if ($n < 900000000000) {
                    // 0.9b-850b
                    $n_format = number_format($n / 1000000000, $precision);
                    $suffix = 'B';
                } else {
                    // 0.9t+
                    $n_format = number_format($n / 1000000000000, $precision);
                    $suffix = 'T';
                }
                // Remove unecessary zeroes after decimal. "1.0" -> "1"; "1.00" -> "1"
                // Intentionally does not affect partials, eg "1.50" -> "1.50"
                if ($precision > 0) {
                    $dotzero = '.' . str_repeat('0', $precision);
                    $n_format = str_replace($dotzero, '', $n_format);
                }

    return $n_format . $suffix;
}number_format_short(1000); // 1K
number_format_short(1110);  // 1.1K
number_format_short(10000); // 10K
number_format_short(1000000); // 1M
...