php 如何把多个一维数组合并成二维数组
Array([activityId]=>36[areaId1]=>7[acDate]=>2013-11-25[activityName]=>111)Array([acti...
Array ( [activityId] => 36 [areaId1] => 7 [acDate] => 2013-11-25 [activityName] => 111 )
Array ( [activityId] => 40 [areaId1] => 7 [acDate] => 2013-11-25 [activityName] => aa )
合并成这样
Array (
[0] =>Array ( [activityId] => 36 [areaId1] => 7 [acDate] => 2013-11-25 [activityName] => 111 ),
[1] =>Array ( [activityId] => 40 [areaId1] => 7 [acDate] => 2013-11-25 [activityName] => bb )
) 展开
Array ( [activityId] => 40 [areaId1] => 7 [acDate] => 2013-11-25 [activityName] => aa )
合并成这样
Array (
[0] =>Array ( [activityId] => 36 [areaId1] => 7 [acDate] => 2013-11-25 [activityName] => 111 ),
[1] =>Array ( [activityId] => 40 [areaId1] => 7 [acDate] => 2013-11-25 [activityName] => bb )
) 展开
展开全部
例程如下:
<?php
header("content-type:text/html;chartset=utf-8");
$a= array(姓名=>array(0=>张三, 1=>李四 ,2=>王五 ));
$b= array (年龄=>array( 0=>23, 1=>24, 2=>25) );
$c= array (城市=>array(0=> 北京 ,1=> 上海 ,2=> 广州) );
$test=array("a"=>姓名,"b"=>年龄,"c"=>城市);
$result = array();
for($i=0;$i<count($a[姓名]);$i++)
foreach($test as $key=>$value)
$result[$i][$value] = ${$key}[$value][$i];
?>
<?php
header("content-type:text/html;chartset=utf-8");
$a= array(姓名=>array(0=>张三, 1=>李四 ,2=>王五 ));
$b= array (年龄=>array( 0=>23, 1=>24, 2=>25) );
$c= array (城市=>array(0=> 北京 ,1=> 上海 ,2=> 广州) );
$test=array("a"=>姓名,"b"=>年龄,"c"=>城市);
$result = array();
for($i=0;$i<count($a[姓名]);$i++)
foreach($test as $key=>$value)
$result[$i][$value] = ${$key}[$value][$i];
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
⊙﹏⊙b汗:
$arr_2 =array();
$arr_2[]=$arr1;
$arr_2[]=$arr2;
……
这里的$arr1,$arr2,……就是你的一维数组
$arr_2 =array();
$arr_2[]=$arr1;
$arr_2[]=$arr2;
……
这里的$arr1,$arr2,……就是你的一维数组
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$array1 = array(1,2);
$array2 = array(3,4);
$array3 = array($array1,$array2);
$array2 = array(3,4);
$array3 = array($array1,$array2);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
例程如下:
<?php
header("content-type:text/html;chartset=utf-8");
$a=
array(姓名=>array(0=>张三,
1=>李四
,2=>王五
));
$b=
array
(年龄=>array(
0=>23,
1=>24,
2=>25)
);
$c=
array
(城市=>array(0=>
北京
,1=>
上海
,2=>
广州)
);
$test=array("a"=>姓名,"b"=>年龄,"c"=>城市);
$result
=
array();
for($i=0;$i<count($a[姓名]);$i++)
foreach($test
as
$key=>$value)
$result[$i][$value]
=
${$key}[$value][$i];
?>
<?php
header("content-type:text/html;chartset=utf-8");
$a=
array(姓名=>array(0=>张三,
1=>李四
,2=>王五
));
$b=
array
(年龄=>array(
0=>23,
1=>24,
2=>25)
);
$c=
array
(城市=>array(0=>
北京
,1=>
上海
,2=>
广州)
);
$test=array("a"=>姓名,"b"=>年龄,"c"=>城市);
$result
=
array();
for($i=0;$i<count($a[姓名]);$i++)
foreach($test
as
$key=>$value)
$result[$i][$value]
=
${$key}[$value][$i];
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询