我有一个名为$questions_data
的数组如下:
Array
(
[question_id] => 24440
[question_parent_id] => 0
[question_subject_id] => 12
[question_topic_id] => 212
[question_directions] =>
[question_text] => <b>Length of the common chord of the circles <i>x</i><sup>2</sup> + <i>y</i><sup>2</sup> &ndash; 2<i>x</i> &ndash; 4<i>y</i> + 1 = 0 and <i>x</i><sup>2</sup> + <i>y</i><sup>2</sup> &ndash; 4<i>x</i> &ndash; 2<i>y</i> + 1 = 0 is</b>
[question_file] =>
[question_description] =>
[question_difficulty_type] => 1
[question_has_sub_ques] => no
[question_picked_individually] => no
[question_appeared_count] => 0
[question_manual] => 0
[question_site_id] =>
[question_created_staff_id] => 4e4078987c90dbf4ee477f480ad1b874
[question_added_date] => 1326869354
[question_updated_staff_id] => 706b8d833fbc4045ed046d500317bfa7
[question_updated_date] => 1338439487
[answer] => Array
(
[0] => Array
(
[answer_id] => 573997
[answer_text] => <img src="/ckeditor_3.6.1//plugins/ckeditor_wiris/integration/showimage.php?formula=c836fa6f0f39de5b559b8b843c176c4f.png" alt="�math xmlns=�http://www.w3.org/1998/Math/MathML���msqrt��mn�14�/mn��/msqrt��/math�" class="Wirisformula" title="Double click to edit" align="middle">
[answer_file] =>
[answer_is_right] => 1
)
[1] => Array
(
[answer_id] => 573998
[answer_text] => <img src="/ckeditor_3.6.1//plugins/ckeditor_wiris/integration/showimage.php?formula=ac4e047dae78ab6f3155f0fab77153f2.png" alt="�math xmlns=�http://www.w3.org/1998/Math/MathML���msqrt��mn�15�/mn��/msqrt��/math�" class="Wirisformula" title="Double click to edit" align="middle">
[answer_file] =>
[answer_is_right] => 0
)
[2] => Array
(
[answer_id] => 573999
[answer_text] => <img src="/ckeditor_3.6.1//plugins/ckeditor_wiris/integration/showimage.php?formula=6bcb45270a3cb70e2d8308173a4f5b03.png" alt="�math xmlns=�http://www.w3.org/1998/Math/MathML���mn�2�/mn��msqrt��mn�3�/mn��/msqrt��/math�" class="Wirisformula" title="Double click to edit" align="middle">
[answer_file] =>
[answer_is_right] => 0
)
[3] => Array
(
[answer_id] => 574000
[answer_text] => None of these<br>
[answer_file] =>
[answer_is_right] => 0
)
)
[answer_id] => Array
(
[1] => 573997
[2] => 573998
[3] => 573999
[4] => 574000
)
[previous_sub_ques_status] => no
)
我想访问具有键名['answer']的内部数组。我尝试了以下方式,但它对我不起作用。在这方面你能帮助我吗?
if(!empty($questions_data)) {
$questions_data['question_text'] = clear_p_tag(clear_question_data(html_entity_decode(stripslashes($questions_data['question_text']))));
$questions_data['question_directions'] = clear_p_tag(clear_question_data(html_entity_decode(stripslashes($questions_data['question_directions']))));
foreach ($question_data['answer'] as $val){
$val['answer_text'] = clear_p_tag(clear_question_data(html_entity_decode(stripslashes($val['answer_text']))));
}
}
答案 0 :(得分:3)
这是
foreach ($question_data['answer'] as $val){
而不是
foreach ($questions_data['answer'] as $val){
缺少S