0

所以我有一个多维数组:

我已经将它压平了一层$array= call_user_func_array('array_merge', $array);

现在,当我尝试使用

foreach($array as $field)
{
   echo $field['Section_title'];      // echo id 

}

我通过所有嵌套数组获得结果,但我只想引用每个单独的数组。而不是获得#1,我想获得#2。有人可以教我如何正确阅读和引用嵌套数组吗?

1.{情况和症状、紧急联系人等}

2.{条件和症状}

数组

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [Section_title] => Conditions and Symptoms
                    [section_subtitle] => Does the patient have 
                    [additional_info] => 
                    [section_disclaimer] => 
                    [disclaimer_title] => 
                    [section_makercol] => 
                    [field_title_1] => Tuberculosis
                    [field_title_2] => Chronic cough
                    [field_title_3] => Asthma
                    [field_title_4] => Diabetes

                )

            [1] => Array
                (
                    [Section_title] => Emergency Contacts
                    [section_subtitle] => 
                    [additional_info] => 
                    [section_disclaimer] => 
                    [disclaimer_title] => 
                    [section_makercol] => 
                    [field_title_1] => Name
                    [field_title_2] => Phone #
                    [field_title_3] => Address
                    [field_title_4] => City

                )

            [2] => Array
               ( 

               )
)
4

1 回答 1

2

您可以遍历键值:

foreach($array as $field)
{
   foreach ($field as $key => $value){
       echo $field[$key]; //
   }
}
于 2013-05-10T18:39:17.100 回答