I have a Function to generate random string ,and funtion to repeat it .but how to make it generating more than 1 or according to the written in parameter?
function generatorstring($length = 7){
$karakter = '0123456789abcdefghijklmnopqrstuvwxyz';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $karakter[rand(0, strlen($karakter) - 1)];
}
return $randomString;
}
function repeat($rpt){
for ($i = 0; $i < $rpt; $i++){
$res = generatorstring();
}
return $res;
}
echo repeat(3);
I expected result like this
'As6s8Xs',
'zE71jnM',
'ak9a71b',
But, its only produce 1 line of random string.
Aucun commentaire:
Enregistrer un commentaire