How to foreach of group an 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;
}