worddrop/humongous

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP library for turning large numbers into numbers formatted as 1.3k.

0.2.2 2014-07-13 10:51 UTC

This package is not auto-updated.

Last update: 2020-01-20 03:43:14 UTC


README

A library that helps you create readable and short numbers from numbers that are larger than 999.

Installation

Currently, the only reliable way (and recommended way) to install Humongous is by using PHP's package manager Composer.

Using Composer

{
    "require": {
        "worddrop/humongous": "dev-master"
    }
}

Usage

<?php
use Humongous\Humongous;

$number = 13224;
$niceNumber = Humongous::parse($number, 1);
echo $niceNumber; // 13.2k

API

Humongous::parse(int $number, int $precision = 1, string $decimalSeparator = '.');

Parameters

  • $number The number that has to be formatted.
  • [$precision = 1] The number of decimals that have to be preserved (0's will automatically be trimmed off)
  • [$decimalSeparator = '.'] A character to separate the decimals.

Returns string

License

This project is licensed under MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Contributing

You may contribute in any way you want, as long as you agree that your code will be licensed under the same license as the project itself.