PHP code example of griffins / sequence

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

    

griffins / sequence example snippets


    
$allowedChars = 'ABCDEF0123456789';
//the only argument is an optional character dictonary, if not specified the default one is used. (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ)
$sequence = \Sequence\Factory::create($allowedChars);

echo $sequence->next('<yyyy>/????');



$sequence->next('<yyyy>/????',null,'2018/AAAA')



$sequence = \Sequence\Factory::create();

$id =  $sequence->next('<yyyy>/????', function($id){
    //check if its exits in a dataset, 
    
    if($exists){
        return true;
    }else{
        // looks like we found a valid id
        return false;
    }
});
// now use the id generated

echo $id;