php group array code example
Example: group array php by key
private function group_by($array, $key) {
$return = array();
foreach($array as $val) {
$return[$val->$key][] = $val;
// ou para gettype($val) = array
// $return[$val[$key]][] = $val;
}
return $return;
}