I got this:
foreach($users as $user) {
$newcw = mt_rand(1, 52);
$set = array('val' => $newcw,
}
this basically runs through the user database and give each user a random value between 1 and 52.
How is it possible to give every 2 users one value?
This should work.
$index = $value = 0;
foreach($users as $user) {
if ($index % 2 == 0)
$newcw = $value = mt_rand(1, 52);
else
$newcw = $value
// Do something with $newcw
$index++;
}
It generates a new random number every other time through the loop.
You could do something like:
$oldcw = NULL;
foreach($users as $user) {
if($oldcw){
$newcw = $oldcw;
$oldcw = NULL;
}else{
$newcw = mt_rand(1, 52);
$oldcw = $newcw;
}
....
}