I have a 2 array named data & data1 both are same set of key and value but data1 have some custom key & value so i want to merge in this
data array
[0] => Array
(
[name] => 1
[total] => 1
)
[1] => Array
(
[name] => 2
[total] => 1
)
[2] => Array
(
[name] => 3
[total] => 3
)
data1 array
[0] => Array
(
[name] => 1
[total] => 1
[custom] => 1
)
[1] => Array
(
[name] => 2
[total] => 1
[custom] => 1
)
[2] => Array
(
[name] => 3
[total] => 3
[custom] => 1
)
$test = array_merge(data,data1);
so i used array_merge(data,data1) it shows duplicate
after merge i got like this
print_r(test);
{"name":1,total":"1"}
{"name":1,"total":"1","custom":1}
array_unique(array_merge($array1,$array2), SORT_REGULAR);
Used array_merge() and then perform array_unique()