I want to merge two arrays but with 2 constraints:
- sort by order, according to ID
- if there are two identical IDs, only display it once (no duplicate)
first array :
{
"products": {
"0": {
"title": "myTitle",
"url": "xxxxxx",
"id": "309132"
},
"1": {
"title": "myTitle",
"url": "",
"id": "309123",
},...
}
}
second array :
{
"products": {
"0": {
"title": "myTitle",
"url": "xxxxxx",
"id": "329102"
},
"1": {
"title": "myTitle",
"url": "",
"id": "439023",
},...
}
}
I tried :
$data3 = array_unique(array_merge($data1,$data2), SORT_NUMERIC);
or with SORT_REGULAR
, but I did not achieve my requirements.