我想结合两组不同的数组
First Array
Array
(
[0] => Array
(
[title] => pacifica-aurum-pride-towers
[getName] => pacifica-aurum-pride-towers
[getImg] => test
[getPrice] => 18
[getPlace] => erode
)
)
第二个数组
Array
(
[title] => New1
[getName] => New name
[getImg] => test
[getPrice] => 18
[getPlace] => erode
)
我需要从上面两组不同的数组中得到这个答案
结果数组
Array
(
[0] => Array
(
[title] => pacifica-aurum-pride-towers
[getName] => pacifica-aurum-pride-towers
[getImg] => test
[getPrice] => 18
[getPlace] => erode
)
[1]=>Array
(
[title] => New1
[getName] => New name
[getImg] => test
[getPrice] => 18
[getPlace] => erode
)
)
答案 0 :(得分:1)
您可以通过编写以下声明来完成此操作
$array1[] = $array2;
这会将$array2
添加为$array1
答案 1 :(得分:1)
只需将第二个数组附加到第一个数组,就像这样
remove_all_shortcodes();
答案 2 :(得分:0)
如果你想要,你可以使用array_push,但是在你的第一个数组工作时定义一个新的索引,实际上结果是相同的。
$array1 = array(array('key1'=>'value011', 'key2' => 'value012'));
echo json_encode($array1);
/**
* output: [{"key1":"value011","key2":"value012"}]
*
*
*/
$arrayToPush = array('key1' => 'value021', 'key2' => 'value022');
array_push($array1, $arrayToPush);
echo json_encode($array1);
/**
* output: [{"key1":"value011","key2":"value012"}, {"key1":"value021","key2":"value022"}]
*
*
*/
答案 3 :(得分:0)