问题描述:
后台处理前台提交的表单数组,三个数组同时需要遍历组成新数组,具体如下:
例如:
复制代码 代码示例:
$array1 => array("001","002","003"); //城市编号
$array2 => array("北京","上海","深圳");
$array3 => array("24","27","27");//气温
使用以下方法组合新数组:
复制代码 代码示例:
foreach($array1 as $value1)
{
$value2 = current($array2);
$value3 = current($array3);
$newarray[] = array("$value1","$value2","$value3");
next($array2);
next($array3); //www.jb200.com
}
得到新数组:
复制代码 代码示例:
$newarray = array(
array("001","北京","24"),array("002","上海","27"),array("003","深圳","27")
);
代码简单了点,仅供初学php数组遍历或组合的朋友参考。