randomKey.php
Table of Contents
Functions
- randomKey() : string
- Generates a random key string, optionally prefixed with a given string and separated by a custom separator.
Functions
randomKey()
Generates a random key string, optionally prefixed with a given string and separated by a custom separator.
randomKey(string|null $prefix[, string $separator = '_' ]) : string
The random part is generated using mt_rand()
which provides a pseudo-random integer.
Parameters
- $prefix : string|null
-
Optional prefix to prepend to the key. If null or empty, no prefix is added.
- $separator : string = '_'
-
Separator string between the prefix and the random number. Defaults to underscore '_'.
Tags
Return values
string —The generated random key.