php二维数组
Array("ID"=>Array([0]=>1[1]=>2[2]=>3[3]=>4[4]=>5[5]=>6)"NAME"=>Array([0]=>A[1]=>B[2]=...
Array("ID"=>Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
"NAME"=>Array
(
[0] => A
[1] => B
[2] => C
[3] => D
[4] => E
[5] => F
)
)
如何遍历数组啊!!使他们的值对应起来.
像这样:1=>A 2=>B 3=>C 展开
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
"NAME"=>Array
(
[0] => A
[1] => B
[2] => C
[3] => D
[4] => E
[5] => F
)
)
如何遍历数组啊!!使他们的值对应起来.
像这样:1=>A 2=>B 3=>C 展开
2个回答
2010-06-19
展开全部
$array_source=array("id"=>array(1,2,3,4,5,6),"name"=>array(A,B,C,D,E,F));
$array_target=array();
foreach($array_source["id"] as $key=>$value){
$array_target[$array_source["id"][$key]]=$array_source["name"][$key];
}
结果是:
Array ( [1] => A [2] => B [3] => C [4] => D [5] => E [6] => F )
$array_target=array();
foreach($array_source["id"] as $key=>$value){
$array_target[$array_source["id"][$key]]=$array_source["name"][$key];
}
结果是:
Array ( [1] => A [2] => B [3] => C [4] => D [5] => E [6] => F )
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询