archive

PHP: Change Units

Outputs a human readable number.

1000000000000) return round(($n/1000000000000),1).' trillion';
    else if($n>1000000000) return round(($n/1000000000),1).' billion';
    else if($n>1000000) return round(($n/1000000),1).' million';
    else if($n>1000) return round(($n/1000),1).' thousand';

    return number_format($n);
  }
?>

Outputs:

247,704,360 -> 247.7 million
866,965,260,000 -> 867 billion

Source

Comments are closed.