2017-12-22 3 views
0

의 값을 어떻게 루프 할 것인가? ques_title '? 아래는 코드와 그 출력입니다. 심지어 값을 반복 할려고 시도했는데, 즉 $ i => $ 값이지만 출력이 표시되지 않습니다.PHP에서 배열 값 인쇄

foreach($allquiz as $i) { 
    echo "<pre>"; 
    print_r($i); 
    echo "</pre>"; 
} 

OUTPUT

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" 
} 
} 

내가 모든 변수를 통해 루프를 원하고 저장합니다. 내가 어떻게 해 ?

답변

1
foreach($allquiz as $i) { 
    echo "<pre>"; 
    print_r($i["'ques_title'"]); 
    echo "</pre>"; 
} 
+0

작동하지 않았습니다. 아무것도 인쇄되지 않습니다. – topper1309

+0

Whats는'var_dump ($ allquiz);'를 인쇄합니까? –

+0

예, 질문을 – topper1309