PHP code example of hemker / random-string

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

    

hemker / random-string example snippets


use Hemker\RandomString\RandomStringGenerator;

$generator = new RandomStringGenerator('0123456789', 6);
$string = $generator->create();
// $string is now something random like '395174'

// and of course... you can change settings whenever you want
$generator->chars('abcdefghijklmnopqrstuvwxyz');
$generator->length(10);

use Hemker\RandomString\CharPreset;
use Hemker\RandomString\RandomStringGenerator

// same as above: CharPreset::LETTER_LOWER_CASE == [a-z]
$string = new RandomStringGenerator(CharPreset::LETTER_LOWER_CASE);

use Hemker\RandomString\CharPreset;
use Hemker\RandomString\RandomStringGenerator;

$generator = new RandomStringGenerator(CharPreset::LETTER_UPPER_CASE, 8);
$arrayOfStrings = $generator->create(500);