I am trying to merge arrays in php. Everything is coming from a database and two different results could look like this:
array[0]['id_user'] = 1
array[0]['tokenId'] = 123
array[1]['id_user'] = 2
array[1]['tokenId'] = 456
array[2]['id_user'] = 5
array[2]['tokenId'] = 789
array[0]['id_user'] = 1
array[0]['tokenId'] = 123
array[1]['id_user'] = 2
array[1]['tokenId'] = 752
array[2]['id_user'] = 3
array[2]['tokenId'] = 789
Using array_merge() and then array_unique() should give me something like this I expect:
unique_and_merged_array[0]['id_user'] = 1
unique_and_merged_array[0]['tokenId'] = 123
unique_and_merged_array[1]['id_user'] = 2
unique_and_merged_array[1]['tokenId'] = 456
unique_and_merged_array[2]['id_user'] = 5
unique_and_merged_array[2]['tokenId'] = 789
unique_and_merged_array[3]['id_user'] = 2
unique_and_merged_array[3]['tokenId'] = 752
unique_and_merged_array[4]['id_user'] = 3
unique_and_merged_array[4]['tokenId'] = 789
Then how can I sort by id_user value? I'm not sure to understand the different sorting php functions ...