didatus / random-string
Class for generating random strings with defined parameters
1.1.1
2017-09-30 07:41 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: 5.2.*
This package is auto-updated.
Last update: 2025-06-10 05:23:16 UTC
README
A simple class for generating random strings.
Create RandomString Instance
use Didatus\RandomString\RandomString; $randomString = new RandomString();
Create RandomString Instance with own character pool and with excluding characters
use Didatus\RandomString\RandomString; $randomString = new RandomString('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '1IO0');
Excluding characters can be helpful for generating readable coupons (without confusing 0 and O for example).
Generate a single random string
$randomString = new RandomString(); $string = $randomString->getString(10);
Generate a single random alpha numeric string excluding confusing characters
$randomString = new RandomString('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '1IO0'); $string = $randomString->getString(10);
generate a list of five random tokens
$randomString = new RandomString(); $strings = $randomString->getListOfString(10, 5);
C8H5