<?php
$aTest = array('apple', 'pineapple', 'banana', 'kiwi', 'pear', 'strawberry', '1234', '#qwerty', '!qwerty');
$range = range('A','Z');
$range[] = "#";
$output = array();
foreach($aTest AS $fruit){
$uc = ucfirst($fruit);
if(array_search($uc[0], $range) === FALSE){
$output['#'][] = $uc;
} else {
$output[$uc[0]][] = $uc;
}
}
print_r($output);
preferences:
43.59 ms | 402 KiB | 5 Q