2
I have 2 PHP strings that are the student’s responses and feedback. I need to compare them and show the result in a table:
$respostas='1;A|2;B|3;C';
$gabaritos='1;A|2;B|3;D';
I need him to generate a table at the end as follows:
Pergunta | Resposta | Gabarito
1 | A | A
2 | B | B
3 | C | D
I made a explode to separate the questions, then a foreach to bring each result and then another explodes to separate the questions and responses to assemble the table of responses, but I do not know how to include the feedback within this table:
$gbarray = explode('|',$respostas);
foreach($gbarray as $resposta){
$questoes = explode(';',$resposta);
$questao = $questoes [0];
$resposta = $questoes [1];
echo '
<tr>
<td>Matéria</td>
<td>'.$questao.'</td>
<td>'.$resposta.'</td>
<td>Reposta Gabarito</td>
<td>Pontuação</td>
<td>% Acerto dos Membros</td>
</tr>
}
Search what the function
array_map
does when you set the first parameter to NULL– Woss