Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
public static function group_by(Array $objects, $group_by_property)
{
$grouped_objects = [];
foreach($objects as $object)
{
$property_value = $object->{$group_by_property};
$grouped_objects[$property_value][] = $object;
}
return $grouped_objects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.