我目前正在手动编写 if else 语句
if ($user_location[0] == $location){
$user_id = $page[0];
} else if ($user_location[1] == $location){
$user_id = $page[1];
} else if ($user_location[2] == $location){
$user_id = $page[2];
} else if ($user_location[3] == $location){
$user_id = $page[3];
} else if ($user_location[4] == $location){
$user_id = $page[4];
} else if ($user_location[5] == $location){
$user_id = $page[5];
} else if ($user_location[6] == $location){
$user_id = $page[6];
} else if ($user_location[7] == $location){
$user_id = $page[7];
} else if ($user_location[8] == $location){
$user_id = $page[8];
} else {
$user_id = $user_gen;
}
如何使这个 if 语句自动递增$user_location[]
and$page[]
而不是手动编码?