https://github.com/nabeghe/shortnum-php
Shortening numbers and using abbreviated letters in PHP.
https://github.com/nabeghe/shortnum-php
number php php-lib php-libraries php-library short-numbers shortnum shortnumber
Last synced: 6 months ago
JSON representation
Shortening numbers and using abbreviated letters in PHP.
- Host: GitHub
- URL: https://github.com/nabeghe/shortnum-php
- Owner: nabeghe
- License: mit
- Created: 2024-10-23T12:50:30.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-10-23T12:51:42.000Z (12 months ago)
- Last Synced: 2025-04-16T00:58:24.077Z (6 months ago)
- Topics: number, php, php-lib, php-libraries, php-library, short-numbers, shortnum, shortnumber
- Language: PHP
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Shortnum for PHP.
> Shortening numbers and using abbreviated letters in PHP.
With Shortnum, you can easily display numbers like 1000 as 1K.
Shortnum supports the following units:`'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc', 'Ud', 'Dd', 'Td', 'Qa', 'Qi', 'Sx', 'Sp',
'Oc', 'No'`
## 🫡 Usage
### 🚀 Installation
You can install the package via composer:
```bash
composer require nabeghe/colory
```
#### Example:
```php
use Nabeghe\Shortnum\Shortnum;echo "1000 => ".Shortnum::short(1000)."\n"; // 1K
echo "1010 => ".Shortnum::short(1010)."\n"; // 1.01K
echo "1049 => ".Shortnum::short(1049)."\n"; // 1.05K
echo "1050 => ".Shortnum::short(1050)."\n"; // 1.05K
echo "1099 => ".Shortnum::short(1099)."\n"; // 1.1K
echo "1100 => ".Shortnum::short(1100)."\n"; // 1.1K
echo "10000 => ".Shortnum::short(10000)."\n"; // 10K
echo "10500 => ".Shortnum::short(10500)."\n"; // 10.5K
echo "15000 => ".Shortnum::short(15000)."\n"; // 15K
echo "100000 => ".Shortnum::short(100000)."\n"; // 100K
echo "1000000 => ".Shortnum::short(1000000)."\n"; // 1M
echo "1000000000 => ".Shortnum::short(1000000000)."\n"; // 1B
echo "1000000000 => ".Shortnum::short(1000000000)."\n"; // 1B
echo "1000000000000 => ".Shortnum::short(1000000000000)."\n"; // 1T
echo "1000000000000000 => ".Shortnum::short(1000000000000000)."\n"; // 1Qa
echo "1000000000000000000 => ".Shortnum::short(1000000000000000000)."\n"; // 1Qi
echo "1000000000000000000000 => ".Shortnum::short(1000000000000000000000)."\n"; // 1Sx
echo "1000000000000000000000000 => ".Shortnum::short(1000000000000000000000000)."\n"; // 1Sp
echo "1000000000000000000000000000 => ".Shortnum::short(1000000000000000000000000000)."\n"; // 1Oc
echo "1000000000000000000000000000000 => ".Shortnum::short(1000000000000000000000000000000)."\n"; // 1No
```
## 📖 License
Copyright (c) Hadi Akbarzadeh
Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.