dev-master
9999999-devConverts base 10 numbers to any set of characters provided, for example an [a-zA-Z] range.
MIT
The Development Requires
- phpunit/phpunit ^5.5.0
- php ^5.6
by Francesco Zaffaroni
Wallogit.com
2017 © Pedro Peláez
Converts base 10 numbers to any set of characters provided, for example an [a-zA-Z] range.
The purpose of this library is to convert decimal numbers to higher bases represented only by alphabet characters to render them easier to remember and easier on the eyes for permalinks and similar applications., (*1)
$ composer require fzaffa/baseconverter
{
"require": {
"fzaffa/baseconverter": "dev-master"
}
}
use Fzaffa\BaseConverter\BaseConverter;
use Fzaffa\BaseConverter\ConverterRangeTypes;
require "vendor/autoload.php"
$converter = new BaseConverter(ConverterRangeTypes::ALPHA_ULCASE);
echo $converter->convert(34523) //Outputs: mNV
echo $converter->convert("mNV") //Outputs: 34523
The convert() method will automatically get the type of the argument, if it is numeric (also a string containing only numbers work) it will convert to a string, if it's a string it will convert to decimal. To force one or the other use convertFromStringToInt or convertFromIntToString., (*2)
The provided ranges are:, (*3)
ConverterRangeTypes::ALPHA_LCASE for [a-z]ConverterRangeTypes::ALPHA_UCASE for [A-Z]ConverterRangeTypes::ALPHA_ULCASE for [a-zA-Z]You can pass in any array of chars that will be used in lieu of their decimal representation (eg. 12 will be the 12th element of the array)., (*4)
Will add tests soon., (*5)
MIT, (*6)
Converts base 10 numbers to any set of characters provided, for example an [a-zA-Z] range.
MIT