WireRandom class

Random generators for ProcessWire

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

Usage example

$random = new WireRandom();
$s = $random->alphanumeric(10);
$i = $random->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 class?     Show args?       Only hookable?    

Common

NameReturnSummary 
WireRandom::alpha()
string

Return string of random ASCII alphabetical letters

 
WireRandom::alphanumeric()
string

Return random alphanumeric, alpha or numeric string

 
WireRandom::arrayKey(array $a)
string int

Get a random key from given array

 
WireRandom::arrayKeys(array $a)
array

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

 
WireRandom::arrayValue(array $a)
mixed null

Get a random value from given array

 
WireRandom::arrayValues(array $a)
array

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

 
WireRandom::base64()
string array

Generate a truly random base64 string of a certain length

 
WireRandom::cryptoSecure()
bool

Is a crypto secure method of generating numbers available?

 
WireRandom::integer()
int array

Get a random integer

 
WireRandom::numeric()
string

Return string of random numbers/digits

 
WireRandom::pass()
string

Generate and return a random password

 
WireRandom::shuffle($value)
string array

Shuffle a string or an array

 
WireRandom::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.252