PHP code example of kotchuprik / php-short-id
1. Go to this page and download the library: Download kotchuprik/php-short-id 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/ */
kotchuprik / php-short-id example snippets
$shortId = new \kotchuprik\short_id\ShortId();
$id = $shortId->encode(422424); // $id will be 'bLTs'
// or with $neededLength = 6
$id = $shortId->encode(422424, 6); // $id will be 'babMwC'
$id = $shortId->decode('bLTs'); // $id will be 424242
// or with $neededLength = 6
$id = $shortId->decode('babMwC', 6); // $id will be 424242