foreach with PHP for two strings

0

Colleagues.

I have the following result coming from the bank:

  

Questions: 1,2,3 Answers: A, B, C

I would like it to look like this:

  

1-A; 2-B; 3-C;

I tried to use two foreach, but it is repeating:

  

1-A; 1-B; 2-A; 2-B;

I did it this way:

$explodeR = explode(",",$jmTurmas->Respostas;
$explodeQ = explode(",",$jmTurmas->Questoes);

       foreach($explodeQ as $exQ){
                foreach($explodeR as $exR){
                  echo $exQ. " - ".$exR."<br>"; 
                }
            } 
    
asked by anonymous 06.06.2016 / 04:50

1 answer

1

So you should give:

$explodeR = explode(",",$jmTurmas->Respostas;
$explodeQ = explode(",",$jmTurmas->Questoes);

foreach($explodeQ as $exQkey => $exQ)
{
    echo $exQ. " - ".$explodeR[$exQkey]."<br>"; 
} 
    
06.06.2016 / 05:01