0
I have the following string that is converted into an array that represents: "Question;Matter ID;Answer":
//PEGANDO AS REPOSTAS
$respostasgabarito='1;1;A|2;1;B|3;1;C|4;1;A|5;1;A|6;2;D|7;2;C|8;2;B|9;2;A|10;2;A';
//SEPARANDO QUESTÕES PELO CARACTER "|"
$questoesgabarito=explode('|',$respostasgabarito);
//FOREACH PARA CADA PERGUNTA PARA SEPARAR PERGUNTA, MATERIA E RESPOSTA
foreach($questoesgabarito as $reposta){
$dividequestoes = explode(';',$reposta);
$pergunta = $dividequestoes[0];
$materia = $dividequestoes[1];
$resposta = $dividequestoes[2];
}
How can I group the $materias
which are the same? In this case, the responses of 1 to 5 would be grouped together and 6 to 10 would be grouped together.
Possible duplicate of Compare 2 array and bring the difference result (grouped by an equal value within the array)
– Woss
Seems to be the same question... what’s the difference?
– Woss
in fact I will delete the other, I simplified the functioning
– Leandro Marzullo