Skip to content

Documentation

Outdated version

You are currently viewing an outdated version of the Short Number library. Switch to the latest version to access the newest features, improvements, and updates.

Lightweight package shortens given number to a short representation of it. For example 1234 will be formatted to 1k and 20244023 to 20m. Package supports multiple languages, the default it's set to English.

Supported PHP Versions

  • ✅ 7.2
  • ✅ 7.3
  • ✅ 7.4
  • ✅ 8.0
  • ✅ 8.1
  • ✅ 8.2
  • ✅ 8.3

Supported Languages

FlagLanguageCode (ISO 639-1)ThousandMillionBillionTrillion
🇬🇧Englishen1k1m1b1t
🇷🇺Russianru1тыс1млн1млд1трн
🇺🇦Ukrainianuk1тис1млн1млд1трн

Usage

php
use Serhii\ShortNumber\Number;

echo Number::conv(20234); // output: "20k"
echo Number::conv(1893234); // output: "1m"

Quick Start

To use Short Number, first, you need to install it via Composer package manager and have minimum PHP version 7.2.

bash
composer require serhii/short-number:^3.0