PHP code example of base62 / base62

1. Go to this page and download the library: Download base62/base62 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/ */

    

base62 / base62 example snippets




use Base62\Base62;

$base62 = new Base62();		// by default use 'basic' driver. It is the default PHP encoder and decoder
$encodedValue = $base62->encode(200000);	// 'Q1O'
$decodedValue = $base62->decode($encodedValue); // 200000



use Base62\Base62;

// unsigned bigint (MySQL) 18446744073709551615
$id = '214748364787898954454';

$base62 = new Base62('gmp');
// print encoded base62 number id
$encodedValue = $base62->encode($id);	// '47rhmv5JHMPe'
$decodedValue = $base62->decode($base62->encode($id)); // '214748364787898954454'