Let's say I have an array that looks like this:
Array
(
[0] => Array
(
[id] => 44091
[epid] => 109912002
[makes] => Honda
[models] => Civic
[years] => 2000
[trims] => All
[engines] => 1.6L 1590CC 97Cu. In. l4 GAS SOHC Naturally Aspirated
[notes] =>
)
[1] => Array
(
[id] => 77532
[epid] => 83253884
[makes] => Honda
[models] => Civic
[years] => 2000
[trims] => All
[engines] => 1.6L 1595CC l4 GAS DOHC Naturally Aspirated
[notes] =>
)
[2] => Array
(
[id] => 151086
[epid] => 109956658
[makes] => Honda
[models] => Civic
[years] => 1999
[trims] => All
[engines] => 1.6L 1590CC 97Cu. In. l4 GAS SOHC Naturally Aspirated
[notes] =>
)
)
And I would like to somehow merge/group/combine whatever you call it if specific key/value pairs are matching.
So my condition would be:
If Makes & Models & Years & Trims is the same, combine into 1 array. The other key/values such as id/epid/trims/engines/notes are not relevant and if possible can just use/inherit 1 of those matched entries.
Once that's possible I want to add another condition to also look for this:
If Makes & Models & Years & Trims & Engines is the same combine into 1 array.
Perhaps I'm confusing myself and both those can be using the same code.
Anyways in this situation I would expect the outcome to look like this afterwards:
Array
(
[0] => Array
(
[id] => 44091
[epid] => 109912002
[makes] => Honda
[models] => Civic
[years] => 2000
[trims] => All
[engines] => 1.6L 1590CC 97Cu. In. l4 GAS SOHC Naturally Aspirated
[notes] =>
)
[1] => Array
(
[id] => 151086
[epid] => 109956658
[makes] => Honda
[models] => Civic
[years] => 1999
[trims] => All
[engines] => 1.6L 1590CC 97Cu. In. l4 GAS SOHC Naturally Aspirated
[notes] =>
)
)
Notice the array with the years of 1999 was not merged.
I tried messing with array_unique, array_flip but couldn't get it to work.
If it matters I'm using PHP 5.6.7.
Hope someone knows what I'm talking about.
Thanks.