Skip to content

Instantly share code, notes, and snippets.

Created June 26, 2013 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5871633 to your computer and use it in GitHub Desktop.
Save anonymous/5871633 to your computer and use it in GitHub Desktop.
// $person - ArrayData w/ assoc arrays, i.e. $person->FIRSTNAME = 'catcher'
foreach($people as $person){
$ll = $person->LASTNAME[0];
$peopleByLetter[$ll]['People'][] = $person;
}
return $this->Customise('PeopleByLetter' => new ArrayList($peopleByLetter);
-------------
<% loop $PeopleByLetter %>
<% loop $People %>
$FIRSTNAME
<% end_loop %>
<% end_loop %>
@micmania1
Copy link

$PeopleByLetter = array();

foreach($people as $person) {
$ll = $person->LASTNAME[0];
if(!array_key_exists($ll, $PeopleByLetter)) {
$PeopleByLetter[$ll] = new ArrayData(array(
"People" => new ArrayList()
));
}
$PeopleByLetter[$ll]->People->push($person);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment