PHP code example of sycho / codecs-base64vlq

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

    

sycho / codecs-base64vlq example snippets


use axy\codecs\base64vlq\Encoder;

$encoder = new Encoder();

$encoder->encode([12345, -12345, 0]); // yjYzjYA
$encoder->decode('yjYzjYA'); //  [12345, 012345, 9]

$encoder->decode('Variable+Length+QuantitY'); // [-10, 13, -13349, -13 ... -12797139]

$encoder = Encoder::getStandardInstance();

Encoder::__construct([array|string $alphabet, int $bits, bool $signed = true])

/* Custom alphabet, 4 bits, no sign transfer */
$encoder = new Encoder('My Alphabet', 3, false);

$encoder->encode([12345, 6789]); // phalllApplhhhy

$encoder->decode('Az'); // VLQ sequence is invalid: [0,51]

$encoder->decode('A*A'); // Base-64 string is invalid: "A*A"

$encoder = new Encoder('qwe', 10);
$encoder->encode([10, 20, 30]); // Number 20 is not found in Base64 alphabet