如何访问内部数组密钥[答案]


How to access internal array key [answer]?

我有一个名为$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> – 2<i>x</i> – 4<i>y</i> + 1 = 0 and <i>x</i><sup>2</sup> + <i>y</i><sup>2</sup> – 4<i>x</i> – 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']))));
          }
        }

读取

foreach ($question_data['answer'] as $val){

而不是

foreach ($questions_data['answer'] as $val){

有一个丢失的s