0
的顯示值我有一個多維數組是這樣的:PHP:陣列,具有共同的列約束
Array (
[0] => Array ([ans_id] => 1 [ans_name] => PHP Hypertext Preprocessor [ques_id] => 1 [right_ans] => Yes [ques_name] => What is the acronym of PHP? [section_id] => 1 [section_name] => PHP)
[1] => Array ([ans_id] => 2 [ans_name] => Preety Home Page [ques_id] => 1 [right_ans] => No [ques_name] => What is the acronym of PHP? [section_id] => 1 [section_name] => PHP)
[2] => Array ([ans_id] => 3 [ans_name] => Programmed Hypertext Page [ques_id] => 1 [right_ans] => No [ques_name] => What is the acronym of PHP? [section_id] => 1 [section_name] => PHP)
[3] => Array ([ans_id] => 4 [ans_name] => Programmed Hypertext Preprocessor [ques_id] => 1 [right_ans] => No [ques_name] => What is the acronym of PHP? [section_id] => 1 [section_name] => PHP))
我的表是這樣的:
ans_id ans_name ques_id right_ans
1 PHP Hypertext Preprocessor 1 Yes
2 Preety Home Page 1 No
3 Programmed Hypertext Page 1 No
4 Programmed Hypertext Preprocessor 1 No
5 Andy Suraski 12 No
6 Zeev Gutman 12 No
7 Rasmus Lerdorf 12 Yes
8 Perl 12 No
我想檢索套的答案常見問題編號
即一套Ques_id='1'
的所有答案,ques_id='12'
等的所有答案的第二套等
我應該使用此代碼:
foreach($all_ans_cat as $r)
{
echo $r['ans_id']." ".$r['ans_name']."<br>";
}
這是檢索所有存在於表作爲一組,又在第二盤被顯示的值相同的值。