当将 2 个数组组合成一个 foreach 循环时,我尝试成功..
<?php
//var
$phone_prefix_array = $_POST['phone_prefix']; //prefix eg. 60 (for country code)
$phone_num_array = $_POST['phone'];
$c_name_array = $_POST['customer_name'];
foreach (array_combine($phone_prefix_array, $phone_num_array) as $phone_prefix => $phone_num) { //combine prefix array and phone number array
$phone_var = $phone_prefix . $phone_num;
$phone = '6' . $phone_var;
if ($phone_prefix == true && $phone_num == true) { //filter if no prefix number dont show
echo $phone;
//customer_name_here
} else {
}
}
?>
结果应该是这样的:
60125487541 Jake
60355485541 Kane
60315488745 Ray
63222522125 Josh
但现在我不确定如何将另一个数组组合$c_name_array
到 foreach lopp
PHP版本:5.2.17