将具有各种对象的两个数组合并为一个数组

时间:2015-10-20 11:39:49

标签: php arrays

我想合并具有各种对象的数组

L.Circle

2 个答案:

答案 0 :(得分:0)

使用php array_merge

array_merge($arr1,$arr2,$arr3).

试试这段代码: -

<?php
$arr=array("zip"=> "560045", "count"=> 1);
$arr1=array("city"=> "Bangalore", "count"=> 1); 
$arr2=array("acount"=> 3, "answer"=> "fgdfgd", "question"=> "comment-about-me-");

print_r(array_merge($arr,$arr1,$arr2));
?>

答案 1 :(得分:0)

在我看来,在PHP中,你应该这样使用:

$arr = array("zip" => "560045", "count" => 1);

//array2
$arr1 = array("city" => "Bangalore", "count" => 1);

//array3
$arr2 = array("acount" => 3, "answer" => "fgdfgd", "question" => "comment-about-me-");

然后:

$final = array_merge($arr, $arr1, $arr2);