PHP code example of nextapps / unique-codes

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

    

nextapps / unique-codes example snippets


// Returns generator to create codes for numbers 1 to 100.
->generate(1, 100);

// Returns array with created codes for numbers 1 to 100.
->generate(1, 100, true);

// Returns string with created code for number 100.
->generate(100);
 php
use Wotz\UniqueCodes\UniqueCodes;

// Generate 100 unique codes for numbers 1 to 100
$codes = (new UniqueCodes())
    ->setObfuscatingPrime(9006077)
    ->setMaxPrime(7230323)
    ->setCharacters('LQJCKZMWDPTSXRGANYVBHF')
    ->setLength(6)
    ->generate(1, 100);

// Result: LWXNHJ (1), LACSVK (2), QLNMNM (3), ... , LYMJHL (100), QJVBVJ (101), LQXGQC (102), ... , LJQ5DJ (7230320), LC17CS (7230321), LZ8J8H (7230322)