PHP code example of choval / base_convert

1. Go to this page and download the library: Download choval/base_convert library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

choval / base_convert example snippets


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

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

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

$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

$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

apt install php-gmp
apt install php-bcmath