1// two arrays one become keys and second becomes values
2array_combine ( array $keys , array $values );
1function custom_array_merge(&$array1, &$array2) {
2 $result = Array();
3 foreach ($array1 as $key_1 => &$value_1) {
4 // if($value['name'])
5 foreach ($array2 as $key_1 => $value_2) {
6 if($value_1['name'] == $value_2['name']) {
7 $result[] = array_merge($value_1,$value_2);
8 }
9 }
10
11 }
12 return $result;
13}
1Input : $a1=array("a"=>"raj", "b"=>"striver");
2 $a2=array("z"=>"geeks", "b"=>"articles");
3Output :
4Array
5(
6 [a] => raj
7 [b] => Array
8 (
9 [0] => striver
10 [1] => articles
11 )
12
13 [z] => geeks
14)