Search
 
SCRIPT & CODE EXAMPLE
 

PHP

PHP Number Shortener

<?php 
function number_shorten($number, $precision = 3, $divisors = null) {
    if (!isset($divisors)) {
        $divisors = array(
            pow(1000, 0) => '', // 1000^0 == 1
            pow(1000, 1) => 'K', // Thousand
            pow(1000, 2) => 'M', // Million
            pow(1000, 3) => 'B', // Billion
            pow(1000, 4) => 'T', // Trillion
            pow(1000, 5) => 'QA', // Quadrillion
            pow(1000, 6) => 'QI', // Quintillion
        );
    }
    foreach ($divisors as $divisor => $shorthand) {
        if (abs($number) < ($divisor * 1000)) {
            // We found a match!
            break;
        }
    }
    return number_format($number / $divisor, $precision) . $shorthand;
}

echo number_shorten(12345678901234567890);
?>
Comment

PREVIOUS NEXT
Code Example
Php :: print average result in php 
Php :: source code in html to add two numbers together 
Php :: laravel migration add contraint to other database 
Php :: laravel livewire public property 
Php :: wordpress redirect attachment page to file 
Php :: CakeResque::enqueue 
Php :: how to prevent iframe for your site by PHP 
Php :: onde que fica a praia escondida no roblox jo mulher maravilha 
Php :: Laravel 9 localization not working on live server 
Php :: 0.01 bnb to php 
Php :: symfony postgresql 
Php :: laravel eloquent where value less then 5 and greter then 0 
Php :: gd2 image resizing library in codeigniter 
Php :: namespace not working php 
Php :: wc-notice-functions.php on line 140 
Php :: phpmaker check master details page 
Php :: passing data from controller to blade view laravel 
Php :: php vender 403 forbidden 
Php :: php inline variables string 
Php :: seed specific seeder laravel 
Php :: numberformatter gujarati 
Php :: dreamweaver laravel plugin 
Php :: adding n days to a DATETIME format value 
Php :: get average of sql column php 
Php :: warning: parameter 2 to search_by_title() expected to be a reference, value given in 
Php :: lista 
Php :: cara cek versi php di laptop 
Php :: wp-config.php location 
Php :: use scope in statamic template 
Php :: laravel yajra datatable Add Column with View 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =