<?php
$array = [
'1-2' => 'stuff',
'3-4' => 'otherstuff',
'2-1' => 'morestuff',
'5-6' => 'evenmorestuff',
'6-5' => 'evenmorestuffagain'
];
$result = array_unique(array_map(function ($key) {
$parts = explode('-', $key);
sort($parts);
return implode('-', $parts);
}, array_keys($array)));
print_r($result);
- Output for 5.6.38, 7.0.33, 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- Array
(
[0] => 1-2
[1] => 3-4
[3] => 5-6
)
preferences:
79.56 ms | 407 KiB | 5 Q