<?php
require 'Str.php';
for ($i = 0; $i <= 5; $i++)
{
echo Str::random(20, true).PHP_EOL;
}
<?php
class Str
{
public static function random($length = 10, $specialChars = false)
{
$pool = 'abcdefghjkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
if ($specialChars)
$pool .= '_?!:@';
return substr(str_shuffle(str_repeat($pool, 5)), 0, $length);
}
}