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;
}
....
}
More Related Contents:
- Using PHP data in MySQL [closed]
- Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘username’@’localhost’ (using password: YES)
- phpmyadmin automatic logout time
- How to execute raw queries with Laravel 5.1?
- MySQL skipping first row
- How to SELECT DEFAULT value of a field
- looping a SQL insert statement with dates
- Auto Increment skipping numbers?
- Query database then email posts from where user is subbed to
- check if link “still” exists [duplicate]
- Gather column name of a table from database [closed]
- CodeIgniter – foreach loop
- How can I do ‘insert if not exists’ in MySQL?
- Can I parameterize the table name in a prepared statement?
- How to find the foreach index?
- Insert query on page load, inserts twice?
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102 [closed]
- Comma separated values in MySQL “IN” clause
- Call to undefined function __() error – phpMyAdmin
- How to store an array into mysql?
- PHP foreach by reference causes weird glitch when going through array of objects
- Using value of a column as index in results using PDO
- How to pass custom type array to Postgres function
- Laravel – Database, Table and Column Naming Conventions?
- mysqli_real_connect(): (HY000/2002): No such file or directory
- Advantages / Disadvantages of pconnect option in CodeIgniter
- Storing arrays in the database
- PHP: Limit foreach() statement? [closed]
- How to check if a value already exists to avoid duplicates?
- Limit pagination page number