PHP code example of princejohnsantillan / id-base-converter

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

    

princejohnsantillan / id-base-converter example snippets


use IdBaseConverter\IdBase;

// Symbols: '0123456789abcdef'
$converter = IdBase::asBase16();

// Symbols: '0123456789ABCDEF'
$converter = IdBase::asBase16uc();

// Symbols: '0123456789abcdefghijklmnopqrstuvwxyz'
$converter = IdBase::asBase36();

// Symbols: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
$converter = IdBase::asBase36uc();

// Symbols: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
$converter = IdBase::asAlphanumeric();

use IdBaseConverter\IdBase;

$converter = IdBase::symbols("0a1b2c3d4e5f6g7h8i9j");

use IdBaseConverter\IdBase;

IdBase::asBase16()->toString(123); // 7b

IdBase::asBase36uc()->toString(123); // 3F

IdBase::symbols("0a1b2c3d4e5f6g7h8i9j")->toString(123); // 3b

use IdBaseConverter\IdBase;

IdBase::asBase16()->toInteger('7b'); // 123

IdBase::asBase16uc()->toInteger('3F'); // 123

IdBase::symbols("0a1b2c3d4e5f6g7h8i9j")->toInteger('3b'); // 123

use IdBaseConverter\IdBase;

IdBase::asAlphanumeric()->convert(12345); // 3d7

IdBase::asAlphanumeric()->convert('3d7'); // 12345