我有一个foreach循环,看起来像在此之前发生了变化,foreach循环检查值上移动
<?php $current_question = "";
foreach ($question_and_answers as $qa) : ?>
<?php $current_question == $qa['current_question']; ?>
<?php if($current_question == $current_question) : ?>
<input type="text" name="question[]" value="<?php echo $qa['question']; ?>"/>
<?php endif; ?>
<?php endforeach; ?>
我想创建一个输入字段中每个循环打新的问题的时候(问题得到返回数次,因为一个问题可以有很多答案)。我所做的似乎并不奏效。
我想看到我的帮助工作的阵列,
Array
(
[0] => Array
(
[question_id] => 2
[question] => What is my name?
[tests_test_id] => 2
[answer_id] => 5
[answer] => Simon
[questions_question_id] => 2
[correct] => true
)
[1] => Array
(
[question_id] => 2
[question] => What is my name?
[tests_test_id] => 2
[answer_id] => 6
[answer] => Dave
[questions_question_id] => 2
[correct] => false
)
[2] => Array
(
[question_id] => 2
[question] => What is my name?
[tests_test_id] => 2
[answer_id] => 7
[answer] => Fred
[questions_question_id] => 2
[correct] => false
)
[3] => Array
(
[question_id] => 2
[question] => What is my name?
[tests_test_id] => 2
[answer_id] => 8
[answer] => John
[questions_question_id] => 2
[correct] => false
)
[4] => Array
(
[question_id] => 3
[question] => What is my surname?
[tests_test_id] => 2
[answer_id] => 9
[answer] => Crawford
[questions_question_id] => 3
[correct] => true
)
[5] => Array
(
[question_id] => 3
[question] => What is my surname?
[tests_test_id] => 2
[answer_id] => 10
[answer] => Caine
[questions_question_id] => 3
[correct] => false
)
[6] => Array
(
[question_id] => 3
[question] => What is my surname?
[tests_test_id] => 2
[answer_id] => 11
[answer] => Rooney
[questions_question_id] => 3
[correct] => false
)
[7] => Array
(
[question_id] => 3
[question] => What is my surname?
[tests_test_id] => 2
[answer_id] => 12
[answer] => Ainley
[questions_question_id] => 3
[correct] => false
)
[8] => Array
(
[question_id] => 4
[question] => What is my favourite colour?
[tests_test_id] => 2
[answer_id] => 13
[answer] => Blue
[questions_question_id] => 4
[correct] => true
)
[9] => Array
(
[question_id] => 4
[question] => What is my favourite colour?
[tests_test_id] => 2
[answer_id] => 14
[answer] => Yellow
[questions_question_id] => 4
[correct] => false
)
[10] => Array
(
[question_id] => 4
[question] => What is my favourite colour?
[tests_test_id] => 2
[answer_id] => 15
[answer] => Green
[questions_question_id] => 4
[correct] => false
)
[11] => Array
(
[question_id] => 4
[question] => What is my favourite colour?
[tests_test_id] => 2
[answer_id] => 16
[answer] => Red
[questions_question_id] => 4
[correct] => false
)
[12] => Array
(
[question_id] => 5
[question] => Who do I support?
[tests_test_id] => 2
[answer_id] => 17
[answer] => Huddersfield Town
[questions_question_id] => 5
[correct] => true
)
[13] => Array
(
[question_id] => 5
[question] => Who do I support?
[tests_test_id] => 2
[answer_id] => 18
[answer] => Leeds United
[questions_question_id] => 5
[correct] => false
)
[14] => Array
(
[question_id] => 5
[question] => Who do I support?
[tests_test_id] => 2
[answer_id] => 19
[answer] => Manchester United
[questions_question_id] => 5
[correct] => false
)
[15] => Array
(
[question_id] => 5
[question] => Who do I support?
[tests_test_id] => 2
[answer_id] => 20
[answer] => Wolverhampton Wanderes
[questions_question_id] => 5
[correct] => false
)
)
我试图通过数组做,循环,每次我遇到一个新的问题,我想outout与值的文本输入的问题。
'似乎没有工作'不是问题描述。 – Bobby