php循环出来数组合并
发布网友
发布时间:2022-04-24 21:44
我来回答
共2个回答
热心网友
时间:2023-10-12 03:02
$data = array();
$len = count($arr);
for($i = 0;$i<$len;$i+=2){
$data[] = array(
'id' => $arr[$i]['id'],
'name' => $arr[$i+1]['name']
);
}
热心网友
时间:2023-10-12 03:03
<?php
$array= array (
array ("id","0004" ),
array ("name","米歇尔"),
array ("id","0005" ),
array ("name","蒋一鸣"),
array ("id","0006" ),
array ("name","杨琰"),
array ("id","0470" ) ,
array ( "name", "章宏"),
array ( "id","0008" ),
array ( "name", "顾瑾婧")
);
$map=array();
$num=count($array)-1;
for ($i=0;$i<$num;$i++){
$arr[]= array (
'id' => $array[$i][1],
'name' => $array[$i+1][1]
);
$map=$arr;
$i++;
};
print_r($map);
?>