PHP-在PHP中打印数组的值
如何循环“ques_title”的值?下面是代码及其输出,我甚至尝试过循环值,即$I=>$value,但没有显示输出PHP-在PHP中打印数组的值,php,arrays,loops,for-loop,foreach,Php,Arrays,Loops,For Loop,Foreach,如何循环“ques_title”的值?下面是代码及其输出,我甚至尝试过循环值,即$I=>$value,但没有显示输出 foreach($allquiz as $i) { echo "<pre>"; print_r($i); echo "</pre>"; } var_dump$allquick 输出: 我想循环所有变量并存储它们。我该怎么做?什么是打印var_dump$allquick?在数组中,键名是'ques_title'with',而不是qu
foreach($allquiz as $i) {
echo "<pre>";
print_r($i);
echo "</pre>";
}
var_dump$allquick
输出:
我想循环所有变量并存储它们。我该怎么做?什么是打印var_dump$allquick?在数组中,键名是'ques_title'with',而不是ques_titletry print_r$i['ques_title'];欢迎来到堆栈溢出!虽然这个代码片段可能是解决方案,但它确实有助于提高文章的质量。请记住,您将在将来回答读者的问题,而这些人可能不知道您的代码建议的原因。谢谢,但我可以知道为什么键名在“with”中吗?
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
)
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"
}
}
foreach($allquiz as $i) {
echo "<pre>";
print_r($i["'ques_title'"]);
echo "</pre>";
}