PHPackages                             choval/base\_convert - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. choval/base\_convert

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

choval/base\_convert
====================

A base convert functino for converting extra large numbers from one base to another

v0.1.1(6y ago)0801MITPHP

Since Aug 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/choval/base_convert)[ Packagist](https://packagist.org/packages/choval/base_convert)[ RSS](/packages/choval-base-convert/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (1)

Choval/base\_convert
====================

[](#chovalbase_convert)

A `base_convert` replacement that doesn't lose precision on large numbers.

A few differences from this convert:

- Second and third parameters (bases) accept:
    - an int between 2 and 64 (0-9a-zA-Z-\_)
    - a string of unique characters
    - an array of unique characters
- A fourth parameter allows passing a padding length for the output
- A fifth parameter can be passed to be used as the padding character, else the first char of the base is used.

Negative numbers are converted to positive, just like `base_convert`.

Install
-------

[](#install)

This function uses the GMP or the BCMath extension. Install one of them.

```
apt install php-gmp
apt install php-bcmath

```

Uses GMP &gt; BCMath &gt; PHP. If vanilla PHP, a `E_USER_WARNING` is triggered.

To Install this library:

```
composer require choval/base_convert

```

Usage
-----

[](#usage)

Procedural:

```
use function Choval\base_convert;
echo base_convert(1000, 10, 16);
// 3e8
```

Object:

```
use Choval\BaseConvert;
echo BaseConvert::from(1000)->to(16);
// 3e8

echo BaseConvert::from('3e8', 16)->to(64);
// fE
```

Padding:

```
$base = 'abcdefghijklmnopqrstuvwxyz';

echo BaseConvert::from(1000)->to($base);
// bmm

echo BaseConvert::from(1000)->to($base, 10);
// aaaaaaabmm

echo BaseConvert::from(1000)->to($base, 10, '#');
// #######bmm

echo base_convert(1000, 10, $base, 10, '#');
// #######bmm

echo BaseConvert::from('#######bmm', $base)->to(10);
// 1000

echo base_convert('#######bmm', $base, 10);
// 1000
```

Keep in mind the type of the parameters, `'10'` and `10` are not the same.

```
$base = 'abcdefghijklmnopqrstuvwxyz';

echo BaseConvert::from('bmm', $base)->to(10);
// 1000

echo BaseConvert::from('bmm', $base)->to('10');
// 0000010111

echo BaseConvert::from('bmm', $base)->to('01');
// 1111101000

echo BaseConvert::from('bmm', $base)->to(2);
// 1111101000
```

License
-------

[](#license)

MIT, see LICENSE

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2464d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7e751254e7e7b319464bd6b51c51d9d2c5fedb4c2305ceaa580f9116cbc6a11?d=identicon)[choval](/maintainers/choval)

---

Top Contributors

[![choval](https://avatars.githubusercontent.com/u/794926?v=4)](https://github.com/choval "choval (3 commits)")

---

Tags

baseconvertbaseconverterphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/choval-base-convert/health.svg)

```
[![Health](https://phpackages.com/badges/choval-base-convert/health.svg)](https://phpackages.com/packages/choval-base-convert)
```

###  Alternatives

[orpheusnet/logchecker

Logchecker for validating logs generated from supported ripping programs (like EAC and XLD)

687.7k](/packages/orpheusnet-logchecker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
