It's a similar question to this one, but sligthly different and I found no answers so far. Take a look at this:
Array
(
[0] => Array
(
['id'] => abc
['value'] => XXX
)
[1] => Array
(
['id'] => abc
['value'] => ooo
)
[2] => Array
(
['id'] => abc
['value'] => qqq
)
[3] => Array
(
['id'] => ghi
['value'] => YYY
)
[4] => Array
(
['id'] => ghi
['value'] => jkl
)
[5] => Array
(
['id'] => ghi
['value'] => XXX
)
[6] => Array
(
['id'] => mno
['value'] => pql
)
)
I want to identify all duplicate values in 2-d arrays, and remove them with a custom condition, as for example in uasort.
For example take the first 3 elements [0], [1], [2]:
I want that XXX wins over the others, so the [1] and [2] will be removed,
Same for [3], [4], and [5]: they have the same id, but YYY wins over XXX and other values.
Since these are data retrieved from a DBMS, one alternative I have is to make N different queries passing the next query the id to exclude, e.g.: "
- Find all elements with YYY
- Find all elements with XXX but that haven't been already found while looking for YYY
- Find all elements without YYY and XXX that haven't been already found while looking for YYY or XXX.
Any help would be appreciated, hope it's all understandable.
Linuxatico