Version 2.4

Random strings – Nette\Utils\Random

Nette\Utils\Random is a static class used for string generating.

random(int $length=10, string $charlist='0-9a-z'): string

Generates a random string of given length from characters specified in second argument. Supports intervals, such as 0-9 or A-Z.

use Nette\Utils\Random;

echo Strings::random(); // '6zq3a1nl8n'
echo Strings::random(5, 'A-Z'); // 'HLKUR'