I\'m having two arrays as follows:
$user_ids = Array
(
[0] => 159a8a6f1c00c5c4d5d0daaab2aa4227
[1] => a39777761f7816031aec676c80c3a8ad
[2] =>
You're close. Since both arrays contain an even amount of values, you can get the $key
while looping the elements as such:
$user_ids = explode(',', $request['items']);
$user_statuses = explode(',', $request['user_status']);
$count = 0;
foreach ($user_ids as $key => $user_id) {
// $key contains the number between the brackets
if($user_statuses[$key]=='disable') {
$objAdminUsers->UpdateUserStatus($user_id, $user_statuses[$key]);
$count++;
}
}
}
This way you don't need a second foreach loop but you simply read the other array simultaneously