$a = array();
foreach($res as $row){
$a[$row['group']][$row['id']][$row['attr']]['name'] = $row['name'];
$a[$row['group']][$row['id']][$row['attr']]['manager'] = $row['manager'];
$a[$row['group']][$row['id']][$row['attr']]['date'] = $row['date'];
...
}
//выдаёт ошибку
foreach($res as $row){
$b = $a[$row['group']][$row['id']][$row['attr']];
$b['name'] = $row['name'];
$b['manager'] = $row['manager'];
$b['date'] = $row['date'];
...
$a[] = $b;
}