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.
Common
Name | Return | Summary | |
---|
WireRandom::alpha() WireRandom::alpha() WireRandom::alpha(int $length = 0, array $options = []) | string | Return string of random ASCII alphabetical letters | |
WireRandom::alphanumeric() WireRandom::alphanumeric() WireRandom::alphanumeric(int $length = 0, array $options = []) | string | Return random alphanumeric, alpha or numeric string | |
WireRandom::arrayKey() WireRandom::arrayKey(array $a) WireRandom::arrayKey(array $a) | string int | Get a random key from given array | |
WireRandom::arrayKeys() WireRandom::arrayKeys(array $a) WireRandom::arrayKeys(array $a, int $qty = 0) | array | Get a random version of all keys in given array (or a specified quantity of them) | |
WireRandom::arrayValue() WireRandom::arrayValue(array $a) WireRandom::arrayValue(array $a) | mixed null | Get a random value from given array | |
WireRandom::arrayValues() WireRandom::arrayValues(array $a) WireRandom::arrayValues(array $a, int $qty = 0) | array | Return a random version of given array or a quantity of random items | |
WireRandom::base64() WireRandom::base64() WireRandom::base64(int $requiredLength = 22, $options = []) | string array | Generate a truly random base64 string of a certain length | |
WireRandom::cryptoSecure() WireRandom::cryptoSecure() WireRandom::cryptoSecure() | bool | Is a crypto secure method of generating numbers available? | |
WireRandom::integer() WireRandom::integer() WireRandom::integer(int $min = 0, int $max = 9223372036854775807, array $options = []) | int array | Get a random integer | |
WireRandom::numeric() WireRandom::numeric() WireRandom::numeric(int $length = 0, array $options = []) | string | Return string of random numbers/digits | |
WireRandom::pass() WireRandom::pass() WireRandom::pass(array $options = []) | string | Generate and return a random password | |
WireRandom::shuffle() WireRandom::shuffle($value) WireRandom::shuffle($value) | string array | Shuffle a string or an array | |
WireRandom::string() WireRandom::string() WireRandom::string(int $length = 0, string $characters = '', array $options = []) | 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.251