$goods = [ 1 => [ 'id' => 12, 'price' => 77, ], 2 => [ 'id' => 43, 'price' => 855, ], 4 => [ 'id' => 34, 'price' => 1, ], ]; $goods_unique_ids_keys = array_keys(array_unique(array_column($goods, 'id'))); $goods_filter_datas = array_filter($goods, fn($key) => in_array($key, $goods_unique_ids_keys), ARRAY_FILTER_USE_KEY);