有关PHP数组的问题,3个数组合成一个数组的数组.
比如有3个数组array1("a","b","c","d")array2("2","3","4","5")array3("a1","a3","a4","a4")如何把这三...
比如有3个数组array1("a","b","c","d")
array2("2","3","4","5")
array3("a1","a3","a4","a4")
如何把这三个数组变成 array([1]=>array("a","2","a1"),[2]=>array("b","3","a3"),[3]=>array("c","4","a4"),[4]=>array("d","5","a4"))
求大神解答,感激不敬 展开
array2("2","3","4","5")
array3("a1","a3","a4","a4")
如何把这三个数组变成 array([1]=>array("a","2","a1"),[2]=>array("b","3","a3"),[3]=>array("c","4","a4"),[4]=>array("d","5","a4"))
求大神解答,感激不敬 展开
2个回答
展开全部
刚好没事帮你写了这个
<?php
$arr1=array("a","b","c","d");
$arr2=array("2","3","4","5");
$arr3=array("a1","a3","a4","a4");
$count=count($arr1);
for($i=1;$i<=$count;$i++){
$tmp[$i]=array(array_shift($arr1),array_shift($arr2),array_shift($arr3));
}
print_r($tmp);
?>
<?php
$arr1=array("a","b","c","d");
$arr2=array("2","3","4","5");
$arr3=array("a1","a3","a4","a4");
$count=count($arr1);
for($i=1;$i<=$count;$i++){
$tmp[$i]=array(array_shift($arr1),array_shift($arr2),array_shift($arr3));
}
print_r($tmp);
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$a1=array("a","b","c","d");
$a2=array("2","3","4","5");
$a3=array("a1","a3","a4","a4");
$a4=array();
foreach($a1 as $key=>$item){
$a4[$key][]=$item;
$a4[$key][]=$a2[$key];
$a4[$key][]=$a3[$key];
}
print_r($a4);
$a2=array("2","3","4","5");
$a3=array("a1","a3","a4","a4");
$a4=array();
foreach($a1 as $key=>$item){
$a4[$key][]=$item;
$a4[$key][]=$a2[$key];
$a4[$key][]=$a3[$key];
}
print_r($a4);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询