如何循环' ques_title' 的值?下面是代码及其输出,我甚至尝试使用循环值,即 $ i => $ value 但是没有显示输出。
foreach($allquiz as $i) {
echo "<pre>";
print_r($i);
echo "</pre>";
}
输出
Array
(
['ques_title'] => Ques 1
['ques_image'] => kitchenaid_mixer_ele_qNhwH.png
['choice_1'] => iphone7_rosegold.png
['choice_2'] => kitchenaid_mixer_ele_qNhwH.png
['choice'] => choice_2
['choice_3'] => iphone7_rosegold.png
['choice_4'] => iphone7_rosegold.png
['question_type'] => 1
)
Array
(
['ques_title'] => Q2
['ques_image'] =>
['choice_1'] => f
['choice_2'] => s
['choice_3'] => t
['choice_4'] => f
['question_type'] => 0
)
的var_dump($ allquiz);
输出:
array(2) {
[0]=>
array(8) {
["'ques_title'"]=>
string(11) "qdea sdas d"
["'ques_image'"]=>
string(30) "kitchenaid_mixer_ele_qNhwH.png"
["'choice_1'"]=>
string(20) "iphone7_rosegold.png"
["'choice_2'"]=>
string(30) "kitchenaid_mixer_ele_qNhwH.png"
["'choice'"]=>
string(8) "choice_2"
["'choice_3'"]=>
string(20) "iphone7_rosegold.png"
["'choice_4'"]=>
string(20) "iphone7_rosegold.png"
["'question_type'"]=>
string(1) "1"
}
[1]=>
array(7) {
["'ques_title'"]=>
string(10) "Q2sad asas"
["'ques_image'"]=>
string(0) ""
["'choice_1'"]=>
string(1) "f"
["'choice_2'"]=>
string(1) "s"
["'choice_3'"]=>
string(1) "t"
["'choice_4'"]=>
string(1) "f"
["'question_type'"]=>
string(1) "0"
}
}
我想循环遍历所有变量并存储它们。我该怎么办?
答案 0 :(得分:1)
foreach($allquiz as $i) {
echo "<pre>";
print_r($i["'ques_title'"]);
echo "</pre>";
}