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}
$data1. Also, these are not arrays - they are JSON objects. You have tojson_decode()them before you can use them in PHP. See 3v4l.org/RDre9{"name":1,total":"1"}is also missing a quote.