The content of this article is about the code implementation of vertical merging & horizontal merging of two-dimensional arrays in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
This article mainly shares with you the first merging method: merging an array through the array_merge method given by PHP's array API. I hope it can help everyone.
Code:
$a = array(array("1","2"),array("3","4")); $b = array(array("a","b"),array("c","d")); $c = array_merge($a,$b); print_r($c);
Result:
After the combination of these methods, the b array is appended to the a array.
Second merging method:
Merge arrays through foreach loop
Code:
$vo) { $list[] = array_merge($vo,$b[$key]); } print_r($list);
Result:
After merging, this method inserts array b into array a.
Related recommendations:
Solution to float to int distortion in PHP
How to use cURL to call WebService to obtain weather information in PHP ( Code)
The above is the detailed content of Code implementation of vertical merging & horizontal merging of two-dimensional arrays in PHP. For more information, please follow other related articles on the PHP Chinese website!