I'm outputting a list of purchases, and I want to automatically highlight the presence of duplicate orders.
Here's what the array looks like. The first two orders are duplicate orders place by mistake. You'll notice that the orderid for each is different, while the email and userid remain the same. So the duplication will need to match on email and / or userid, but not on orderid.
array
0 =>
array
'orderid' => string '2009091008261662'
'email' => string '[email protected]'
'userid' => string '53'
array
1 =>
array
'orderid' => string '2009091008261048'
'email' => string '[email protected]'
'userid' => string '53'
array
2 =>
array
'orderid' => string '2009091008262025'
'email' => string '[email protected]'
'userid' => string '103'
array
3 =>
array
'orderid' => string '2009091008272082'
'email' => string '[email protected]'
'userid' => string '392'
How can I search for duplicate orders from the same person in a given array, in PHP?
I would like to output the above like so:
(pretend its in a table)
2009091008261662 - [email protected] - 53
2009091008261048 - [email protected] - 53
2009091008262025 - [email protected] - 103
2009091008272082 - [email protected] - 392
... so basically just highlight the two ( or more ) duplicates.