如何在以下场景中创建包含所有问题详情的数组?
foreach($question_ids as $question_id) {
/** fetch the question data by question id **/
list($data) = prepare_response($objQuestions->GetQuestionByID($question_id));
}
有人可以帮助我吗?
答案 0 :(得分:1)
喜欢这个吗?
$questionData = array();
foreach($question_ids as $question_id) {
/** fetch the question data by question id **/
list($data) = prepare_response($objQuestions->GetQuestionByID($question_id));
$questionData[$question_id] = $data;
}
var_dump($questionData);
虽然我应该注意,如果$objQuestions->GetQuestionByID
正在运行查询,那么你就是错误的方法,因为不建议在循环内运行查询。