- implode: documentation ( source)
- rand: documentation ( source)
<?php
$num = 0;
while($num != 40){
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$pass = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
//print_r ($pass);
echo implode($pass) . PHP_EOL;
$num++;
}