数组 1 : $gpsArr
Array
(
[store_id] => Array
(
[0] => 101
)
[store_name] => Array
(
[0] => Out of the Blue - Powai
)
[store_logo] => Array
(
[0] => /Out-of-the-Blue-Powai.jpg
)
[deals_image] => Array
(
[0] =>
)
)
阵列 2 : $dataArr
Array
(
[store_id] => Array
(
[0] => 87
[1] => 88
[2] => 99
[3] => 100
)
[store_name] => Array
(
[0] => The Barking Deer Brewpub
[1] => The Den
[2] => Mini Punjab's Chinese Court
[3] => Out of the Blue - Khar
)
[store_logo] => Array
(
[0] => /The-barking-deer-brewpub.png
[1] => /the-den.png
[2] => /Mini-Punjabs-Chinese-Court-Bandra.png
[3] => /Out-of-the-Blue-Khar.jpg
)
[deals_image] => Array
(
[0] => the-barking-deer-brewpub-thumb297.jpg
[1] => the-den-thumb297.jpg
[2] => mini-punjub-chinese-court-thumb297.jpg
[3] => out-of-the-blue-Khar-thumb297.jpg
)
)
通过使用以下代码合并上面的两个数组:
$result = array_unique(array_merge($gpsArr,$dataArr), SORT_REGULAR);
返回以下结果:
Array
(
[store_id] => Array
(
[0] => 87
[1] => 88
[2] => 99
[3] => 100
)
[store_name] => Array
(
[0] => The Barking Deer Brewpub
[1] => The Den
[2] => Mini Punjab's Chinese Court
[3] => Out of the Blue - Khar
)
[store_logo] => Array
(
[0] => /The-barking-deer-brewpub.png
[1] => /the-den.png
[2] => /Mini-Punjabs-Chinese-Court-Bandra.png
[3] => /Out-of-the-Blue-Khar.jpg
)
[deals_image] => Array
(
[0] => the-barking-deer-brewpub-thumb297.jpg
[1] => the-den-thumb297.jpg
[2] => mini-punjub-chinese-court-thumb297.jpg
[3] => out-of-the-blue-Khar-thumb297.jpg
)
)
如您所见store_id = 101
合并数组后不显示。为什么会这样?我想我做了什么愚蠢的事情,但你能告诉我我做错了什么吗?
提前谢谢。
尝试使用 array_merge_recursive()