我有两个数组如下:
$user_ids = Array
(
[0] => 159a8a6f1c00c5c4d5d0daaab2aa4227
[1] => a39777761f7816031aec676c80c3a8ad
[2] => 348703d858f2f36f3fed0da29d04a905
[3] => 05ce989ed54dcd3ecca8af9e0e373c5c
[4] => 2fe40d28847aad4f23ebf74cd93b7235
[5] => 717dce4998cc4f2b926a7a731c2ee651
[6] => 5d3dbc660f5896f790ad15cc40b14209
[7] => 41e400183bb54c2dd25dcd2f062a7ca9
[8] => a8e0f96c0f68242df08c91d58e14d5aa
[9] => ddb29b7d35a24b5bad77bab752ec921b
[10] => eaf925c5e43f387d7d0eba7ee45856e3
[11] => 5291d6ee6c5b577514e832f077a496ca
[12] => 89f9e41b866c8e1c09e66e183a4b9265
[13] => 836d8a3e18888ee2b79b9636a8227c08
[14] => f9f3830700718df102c6c54bc004bdf9
[15] => 982e5d10baf398cb07a0ed388d8e1577
[16] => eb461f406d36a46db88f59f4c0b7b7f1
[17] => 9bfd556bd9ee849048690898a9d1ed3c
[18] => 1f7ec7180354a8741d4e86949e5922fe
[19] => 75cd2b01677ac49306caed58b26d4781
)
$user_status = Array
(
[0] => enable
[1] => disable
[2] => enable
[3] => disable
[4] => disable
[5] => disable
[6] => disable
[7] => enable
[8] => disable
[9] => disable
[10] => disable
[11] => disable
[12] => disable
[13] => enable
[14] => disable
[15] => disable
[16] => disable
[17] => enable
[18] => disable
[19] => enable
)
第一个数组给出 user_ids,而另一个数组给出每个 user_id 的相应状态。因此,上述两个数组将始终具有相同的编号。的元素。现在我想要实现的是为user_ids数组的每个元素(user_id)调用一个函数。但在此之前,我必须检查将在函数调用中使用的 user_id 的状态是否应该禁用。如果 user_id 的状态为启用,则不应调用该函数,并且下一个 user_id 应开始执行。我无法为这种情况编写正确的逻辑。你能帮我吗?提前致谢。我尝试的PHP代码如下:
$user_ids = explode(',', $request['items']);
$user_statuses = explode(',', $request['user_status']);
$count = 0;
foreach ($user_ids as $user_id) {
foreach ($user_statuses as $user_status) {
if(user_status=='disable') {
$objAdminUsers->UpdateUserStatus($user_id, $user_status);
$count++;
}
}
}