Recommend this page to a friend!
  Classes of FN  >  PHP Base Converter  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Base Converter
Convert number representations between two bases
Author: By
Last change:
Date: 1 year ago
Size: 1,804 bytes


Class file image Download


Build Status GitHub version Code Coverage


BaseConverter is a simple and small library to convert interger values to different other bases and back.

Install via composer

Just run the following command in your project root:

composer require neoblack/base-converter:~1.0

Example usage

require_once 'vendor/autoload.php';
use NeoBlack\BaseConverter\BaseConverter;

$number = 100;

$base64Number = BaseConverter::toBase($number, BaseConverter::BASE64); // Result: 1A
$base62Number = BaseConverter::toBase($number, BaseConverter::BASE62); // Result: 1C
$base32Number = BaseConverter::toBase($number, BaseConverter::BASE32); // Result: 34
$base16Number = BaseConverter::toBase($number, BaseConverter::BASE16); // Result: 64

BaseConverter::to10Base($base64Number, BaseConverter::BASE64); // Result: 100
BaseConverter::to10Base($base62Number, BaseConverter::BASE62); // Result: 100
BaseConverter::to10Base($base32Number, BaseConverter::BASE32); // Result: 100
BaseConverter::to10Base($base16Number, BaseConverter::BASE16); // Result: 100

Developer Notes

If you want to contribute, fork this repository and send a pull request.

Unit Test

./bin/phpunit -c Build/UnitTests.xml

Coverage report

rm -rf docs
./bin/phpunit -c Build/UnitTests.xml --coverage-html docs


The MIT License (MIT) see license file.

For more information send a message to info at phpclasses dot org.