PHP Rakam Format Ayarlama

1M 10K gibi kısaltmalar kullanabilceğiniz fonksiyon

PHP Rakam Format Ayarlama
<?php 
    function format_number($number) {
        // first strip any formatting;
        $number = (0+str_replace(",", "", $number));
 
        // is this a number?
        if (!is_numeric($number)) return false;
 
        // now filter it;
        if ($number > 1000000000000) return round(($number/1000000000000), 2).'T';
        elseif ($number > 1000000000) return round(($number/1000000000), 2).'B';
        elseif ($number > 1000000) return round(($number/1000000), 2).'M';
        elseif ($number > 1000) return round(($number/1000), 2).'K';
 
        return number_format($n);
    }
 
echo format_number('8700000');
echo format_number('53420');
?>