dimanche 8 février 2015

Generating random numbers in PHP with existing code

I'm using the following code and am getting 6 random characters. How can I increase the number of characters to 10 (or any other number)? What in this code makes it 6 characters?



function createRandomID() {

$chars = "abcdefghijkmnopqrstuvwxyz0123456789?";

$i = 0;

$pass = "";

while ($i <= 5) {

$num = rand() % 33;

$tmp = substr($chars, $num, 1);

$pass = $pass . $tmp;

$i++;

}
return $pass;
}




Aucun commentaire:

Enregistrer un commentaire