<?php
$array = [
['x' => 0.5, 'y' => 23],
['x' => 23, 'y' => 21.75],
['x' => 14.25, 'y' => 21.875],
['x' => 19.375, 'y' => 21.75],
['x' => 9.125, 'y' => 21.875],
['x' => 23, 'y' => 19.625],
['x' => 19.375, 'y' => 19.625],
];
foreach ($array as $row) {
if (!isset($result['#' . $row['y']])) {
$result['#' . $row['y']] = $row;
}
}
var_export(array_values($result));
preferences:
37.68 ms | 405 KiB | 5 Q