Last active
February 27, 2018 13:26
-
-
Save begnini/a4ba25f9f33e16233f1b8f8050614c5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function agrupa_alunos($query) | |
{ | |
$alunos = []; | |
foreach ($query->result() as $key => $value) | |
{ | |
$id = $value->numerodoaluno; | |
if (empty($alunos[$id])) { | |
/* inicializa os dados do aluno, com os dados basicos | |
* e disciplina vazia */ | |
$alunos[$id] = [ | |
'id' => $id, | |
'nome' => $value->nomedoaluno, | |
'disciplinas' => [] | |
]; | |
} | |
$alunos[$id]['disciplina'][] = $value->disciplina_descricao; | |
} | |
return $alunos; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment