<?php
$articles = [
[
"id" => 0,
"title" => "lorem",
"reference" => "A"
],
[
"id" => 1,
"title" => "ipsum",
"reference" => "B"
],
[
"id" => 2,
"title" => "dolor",
"reference" => "C"
],
[
"id" => 3,
"title" => "sit",
"reference" => "A"
]
];
$found = [];
foreach ($articles as $index => ['reference' => $ref]) {
if (!isset($found[$ref])) {
$found[$ref] = $index;
} else {
unset($articles[$index], $articles[$found[$ref]]);
}
}
var_export($articles);
preferences:
27.52 ms | 402 KiB | 5 Q