多维数组循环

I have a multidimensional array

return array(

// This level separates instances by their instance key.
'cytec' => array(

    // This level separates models by their model key.
    'model1' => array(

        'title'   => 'Business card model 1 title',
        'preview' => 'public path to preview image',
        'pdf'     => 'web safe path to PDF to generate from',
        'fields'  => array(

            'title' => array(
                'label'        => 'Title',
                'type'         => 'text',
                'required'     => true,
                'coordinate-x' => 30,
                'coordinate-y' => 20,
                'rules'        => 'required',
            ),

            'phone' => array(
                'label'        => 'Phone',
                'type'         => 'text',
                'help'         => 'syntax +32(0)3 485 85 53', 
                'coordinate-x' => 40,
                'coordinate-y' => 20,
                'rules'        => '',
            ),

            'position' => array(
                'label'        => 'Position',
                'type'         => 'select',
                'options'      => array(
                    'developer' => 'Web Developer',
                    'designer'  => 'Web Designer',
                ),
                'required'     => true,
                'coordinate-x' => 40,
                'coordinate-y' => 20,
                'rules'        => 'required|in:developer,designer',
            ),
        ),
    ),
),
);

and I get this returned

Array ( 
   [model1] => Array ( 
                  [title] => Business card model 1 title 
                  [preview] => public path to preview image 
                  [pdf] => web safe path to PDF to generate from 
                  [fields] => Array ( 
                                 [title] => Array ( 
                                              [label] => Title 
                                              [type] => text 
                                              [required] => 1 
                                              [coordinate-x] => 30 
                                              [coordinate-y] => 20 
                                              [rules] => required 
                                           )
                                 [phone] => Array ( 
                                              [label] => Phone 
                                              [type] => text 
                                              [help] => syntax +32(0)3 485 85 53 
                                              [coordinate-x] => 40 
                                              [coordinate-y] => 20 
                                              [rules] => 
                                           ) 
                                 [position] => Array ( 
                                                [label] => Position 
                                                [type] => select 
                                                [options] => Array ( 
                                                               [developer] => Web Developer
                                                               [designer] => Web Designer
                                                             ) 
                                                [required] => 1 
                                                [coordinate-x] => 40 
                                                [coordinate-y] => 20 
                                                [rules] => required|in:developer,designer 
                                              ) 
                             ) 
                )
  )

but now I wan't to loop through this and just get the name of array model1 back.
How do I do this? I don't need the values of the array model 1 just the name

查看全部
douben7260
douben7260
2013/04/15 07:32
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

4个回复