lundi 19 octobre 2015

Php random numbers inside foreach

I got this:

foreach($users as $user) {

    $user = mt_rand(1, 52);

    ...
}

this loops through the users in my database and randoms a number between 1 and 52 for each user.

Later it update the db and writes in the randomed number.

Is it possible to give a user a unique number, so that one user does not get the same number as another?




Aucun commentaire:

Enregistrer un commentaire