WireRandom class

Includes methods for random strings, numbers, arrays and passwords.

Usage example

$rand = new WireRandom();
$s = $rand->alphanumeric(10);
$i = $rand->integer(0, 10);

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireRandom class also inherits all the methods and properties of: Wire.

Show $var?     Show args?       Only hookable?    

Common

NameReturnSummary 
$rand->alpha()
string

Return string of random ASCII alphabetical letters

 
$rand->alphanumeric()
string

Return random alphanumeric, alpha or numeric string

 
$rand->arrayKey(array $a)
string int

Get a random key from given array

 
$rand->arrayKeys(array $a)
array

Get a random version of all keys in given array (or a specified quantity of them)

 
$rand->arrayValue(array $a)
mixed null

Get a random value from given array

 
$rand->arrayValues(array $a)
array

Return a random version of given array or a quantity of random items

 
$rand->base64()
string array

Generate a truly random base64 string of a certain length

 
$rand->cryptoSecure()
bool

Is a crypto secure method of generating numbers available?

 
$rand->integer()
int array

Get a random integer

 
$rand->numeric()
string

Return string of random numbers/digits

 
$rand->pass()
string

Generate and return a random password

 
$rand->shuffle($value)
string array

Shuffle a string or an array

 
$rand->string()
string

Generate a random string using given characters

 

Additional methods and properties

In addition to the methods and properties above, WireRandom also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.257