我有一個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