I have an array containing arrays of names and other details, in alphabetical order. Each array includes the first letter associated with the name.
Array
(
You can group them easily, even if they aren't sorted:
$groups=array();
foreach ($names as $name) {
$groups[$name[0]][] = $name[1];
}
You don't even need to store the first initial to group them:
$names = array(
'Alanis Morissette',
'Alesha Dixon',
'Alexandra Burke',
'Britney Spears',
'Bryan Adams',
...
);
$groups=array();
foreach ($names as $name) {
$groups[$name[0]][] = $name;
}