This Library converts Integers to Letters using A-Z. 0 = A, 25 = Z, using that, we can convert any integer to a letter format.
Install using composer
composer require levizwannah/php-nums-to-letters
Converts numbers to Letter format (Capital letters only);
use LeviZwannah\PhpNumsToLetters\Converter;
$letters = Converter::toLetters(12345);
Converts letters to number format. The letters will be converted to uppercase first.
use LeviZwannah\PhpNumsToLetters\Converter;
$number = Converter::toNumber('AABC');
This method tries to efficiently compares $val1 and $val2. Either of them can be string|integers. The comparison will still work.
use LeviZwannah\PhpNumsToLetters\Converter;
Converter::isEqual(1, 'B'); // true
Converter::isEqual(1, 1); // true;
Converter::isEqual('B', 'B'); // true;
Converter::isEqual(0, 'B'); // false
Converter::isEqual('dw', 'DW'); // true
Only Capital letters are used. Not lowercase so that we don't have any confusion. Imagine an Invoice number being AaBbC. That doesn't look good.
When the number has a negative sign, the sign will be preserved in the conversion. For example, -1 = -B and -C = -2.
Only Integers are supported at the moment because 1/26 gives a very long decimal.
With only 7 Letters, you can represent -8,031,810,176 to 8,031,810,176 numbers.
- Beautiful Order Invoice Numbers from Order IDS or some random Number.
- Representing IDs