PHP code example of sqids / sqids

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

    

sqids / sqids example snippets


use Sqids\Sqids;
$sqids = new Sqids();

$sqids = new Sqids();
$id = $sqids->encode([1, 2, 3]); // "86Rf07"
$numbers = $sqids->decode($id); // [1, 2, 3]

$sqids = new Sqids(minLength: 10);
$id = $sqids->encode([1, 2, 3]); // "86Rf07xd4z"
$numbers = $sqids->decode($id); // [1, 2, 3]

$sqids = new Sqids(alphabet: 'FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE');
$id = $sqids->encode([1, 2, 3]); // "B4aajs"
$numbers = $sqids->decode($id); // [1, 2, 3]

$sqids = new Sqids(blocklist: ['86Rf07']);
$id = $sqids->encode([1, 2, 3]); // "se8ojk"
$numbers = $sqids->decode($id); // [1, 2, 3]