You can iterate on the names, and get the year, and store the information in a map
<?
foreach($models as $model){
$type = substr($model, 0, -5);
$year = substr($model, -4);
if (!isset($results[$type])) {
$results[$type] = array('min'=> $year, 'max'=>$year);
} else {
$results[$type]['min']=min($results[$type]['min'], $year);
$results[$type]['max']=max($results[$type]['max'], $year);
}
}
foreach($results as $type=>$years){
if ($years['min']==$years['max']){
$years_string = $years['min'];
} else {
$years_string = $years['min'],'-',$years['max'];
}
echo $type,' ', $years_string, "\n";
}
?>
Check this fiddle: http://codepad.org/kOe5pi1S