- print_r: documentation ( source)
- array_values: documentation ( source)
- explode: documentation ( source)
- natsort: documentation ( source)
<?php
$array = array("100_1", "100_2", "100_3", "100_11", "111_1", "111_2", "111_11", "101_1", "102_1", "102_2", "103_1", "103_2", "103_3", "104_1", "104_2");
natsort($array);
foreach($array as $value) {
$parts = explode('_', $value);
$result[$parts[0]] = $value;
}
$result = array_values($result);
print_r($result);