The PHP 7 has a function called random_bytes that if you convert from binary to Hex, generates a string similar to what you want.
<?php
// Usando a função random_bytes do PHP 7
for ($x = 1; $x <= 10; $x++)
{
echo bin2hex(random_bytes(3)) . "<br>"; // gera uma string pseudo-randômica criptograficamente segura de 6 caracteres
}
?>
Example of output(changes every time you run the script):
eb5a35
ce5121
d5c514
e4eec4
48d781
52367c
ae39cd
5ef0ff
dfe681
0ac13f
Reference:
https://secure.php.net/manual/en/function.random-bytes.php
But if you still do not use PHP7 or did not like the option with hexadecimal used by the existing function in PHP7, an interesting technique that I saw in Stack Overflow in English and adapted here is with the use of str_shuffle, a function that randomly shuffles strings. This function is present in PHP from PHP 4.
<?php
// Usando str_shuffle (mistura strings aleatoriamente)
for ($x = 1; $x <= 10; $x++)
{
//Inclua todos os caracteres que gostaria que aparecessem nas strings geradas
$caracteres_q_farao_parte = 'abcdefghijklmnopqrstuvwxyz0123456789';
$password = substr( str_shuffle($caracteres_q_farao_parte), 0, 6 );
echo $password . "<br>";
}
?>
Example of output(will come out different every time you run the script):
yc7dj6
g57rt0
prwgdn
hctvog
d2l0cq
r78fp1
0z6c4e
95m8fa
19bnx5
vyw8p6
Reference: http://php.net/manual/en/function.str-shuffle.php
Have you read the discussion Generate string securely random in PHP?
– Woss
Or the Create different random password for each loop record?
– Woss