I did not understand what you want to do with 'correct_answer'
but I think that replacing your controller code by this, it should help you (except maybe the field 'correct_answer'
but the principle will the same for the rest).
$getQ = new Questions();
$res = $getQ->getQuestionByID();
$res_ans = $getQ->getMcq();
$questions = array();
foreach ($res as $que) {
$tmp = array();
$tmp['question'] = $que->questionDesc;
$index = 0;
foreach ($res_ans as $ans) {
if ($ans->questionID == $que->questionID){
$tmp['answer'][] = $ans->answerDesc;
if ($ans->isAnswer == 1) {
$tmp['correct_answer'] = $index;
}
$index++;
}
}
array_push($questions, $tmp);
}
echo "<pre>";
print_r($questions);
echo "</pre>";