- sort: documentation ( source)
- range: documentation ( source)
- ucfirst: documentation ( source)
<?php
$aTest = array('apple', 'pineapple', 'banana', 'kiwi', 'pear', 'strawberry', '1234', '#qwerty');
$range = range('A','Z');
$range[] = '#';
$output = array();
foreach($range AS $letters){
foreach($aTest AS $fruit){
if(ucfirst($fruit[0]) == $letters){
$output[$letters][] = ucfirst($fruit);
}
}
}
foreach($output AS $letter => $fruits){
echo $letter . "<br/>--------<br/>\n";
sort($fruits);
foreach($fruits AS $indFruit){
echo $indFruit . "<br/>\n";
}
echo "<br/>\n";
}
?>