I'm attempting to check the next item in the array's sub-items for matching values of only some of the sub-items, then delete found matches.
I'll eventually need to add code before the deletion which will collect the difference between sub-items if a match is found so I can't simply use array_unique().
The following works to an extent;
$n = 1;
for ($i = 0; $i < count($array); $i++) {
if($array[$i]['author'] == $array[$n]['author']
&& $array[$i]['parentID'] == $array[$n]['parentID']) {
unset($array[$n]);
//skip the removed item and continue;
$i++;
$n++;
}
$n++;
}
However, it only removes one instance and leaves any matching following conditions. (1 removed below, but 2 not removed)
[0] => Array
(
[parentID] => 85560
[author] => Carla
[revisions] => 1
)
[2] => Array
(
[parentID] => 85560
[author] => Carla
[revisions] => 2
)
[3] => Array
(
[parentID] => 85560
[author] => Charlie
[revisions] => 4
)
Here is the initial input;
[0] => Array
(
[parentID] => 85560
[author] => Carla
[revisions] => 1
)
[1] => Array
(
[parentID] => 85560
[author] => Carla
[revisions] => 2
)
[2] => Array
(
[parentID] => 85560
[author] => Carla
[revisions] => 2
)
[3] => Array
(
[parentID] => 85560
[author] => Charlie
[revisions] => 4
)