我如何在开发人员阵列中获得访问权限?

时间:2015-03-31 19:58:34

标签: php arrays loops foreach

$employees = array( 'Internee' =>
                                array(
                                        'name'      =>       'Nabeel Salman',
                                        'salary'    =>       'Non-Paid',
                                        'join_date' =>       '12-12-2014',
                                        'skills'    => array('php',
                                                             'mysql'),
                                        'phone'     => array('0332-8700207',
                                                             "052-42900092"),
                                        'address'   => array('addr'         => 'Karigar Web Solutions',
                                                             'perm_addr'    => 'Sadar Cantt',
                                                             'city'         => 'Sialkot',
                                                             'province'     => 'Punjab',
                                                             'country'      => 'Pakistan',
                                                             'zipcode'      => "51310"),
                                        'work hours' =>     "7.5"
                                    ),
                    'CEO' =>
                                array(
                                        'name'      =>       'Muhammad Faisal',
                                        'salary'    =>        "100000",
                                        'join_date' =>       '12-12-2009',
                                        'skills'    => array('php',
                                                             'mysql',
                                                             'JavaScript',
                                                             'jQuery',
                                                             'Laravel',
                                                             'CodeIgnitor'),
                                        'phone'     => array('0321-9999999',
                                                             "052-4582565"),
                                        'address'   => array('addr'         => 'Karigar Web Solutions',
                                                             'perm_addr'    => '35 Holdenhurst Road, Bournemouth, Dorset, BH8 8EJ',
                                                             'city'         => 'Sialkot',
                                                             'province'     => 'Punjab',
                                                             'country'      => 'Pakistan',
                                                             'zipcode'      => "51310"),
                                        'work hours' =>     "7.5"
                                    ),
                    'Developers' =>
                        array( 'Developer1' => 
                                    array(
                                        'name'      =>       'Wasif Iqbal',
                                        'salary'    =>        "35000",
                                        'join_date' =>       '24-3-2014',
                                        'skills'    => array('php',
                                                             'mysql',
                                                             'JavaScript',
                                                             'jQuery',
                                                             'Laravel'),
                                        'phone'     => array('0333-8694862',
                                                             "052-4111111"),
                                        'address'   => array('addr'         => 'Karigar Web Solutions',
                                                             'perm_addr'    => 'Defense Road',
                                                             'city'         => 'Sialkot',
                                                             'province'     => 'Punjab',
                                                             'country'      => 'Pakistan',
                                                             'zipcode'      => "51310"),
                                        'work hours' =>     "7.5"
                                    ),

                                'Developer2'=>
                                    array(      
                                        'name'      =>       'Bilal',
                                        'salary'    =>        "35000",
                                        'join_date' =>       '24-3-2014',
                                        'skills'    => array('php',
                                                             'mysql', 'Networking',
                                                             'jQuery',
                                                             'JavaScript',
                                                             'Laravel'),
                                        'phone'     => array('0332-9900997',
                                                             "052-42897678"),
                                        'address'   => array('addr'         => 'Karigar Web Solutions',
                                                             'perm_addr'    => 'Somewhere in Sialkot',
                                                             'city'         => 'Sialkot',
                                                             'province'     => 'Punjab',
                                                             'country'      => 'Pakistan',
                                                             'zipcode'      => "51310"),
                                        'work hours' =>     "7.5"
                                    ),
                            ),
                    'Manager'=>
                                array(
                                        'name'      =>       'Fahad Maqsood',

                                        'salary'    =>       '80000',

                                        'join_date' =>       '12-12-2009',

                                        'skills'    => array('Management', 'Accounting'),

                                        'phone'     => array('+923217435809', "+13236866002"),

                                        'address'   => array('addr'         => 'Karigar Web Solutions',
                                                             'perm_addr'    => 'Shifting to a new place, will update in a few days.',
                                                             'city'         => 'Sialkot',
                                                             'province'     => 'Punjab',
                                                             'country'      => 'Pakistan',
                                                             'zipcode'      => "51310"),

                                        'work hours' =>     "7.5"
                                    ),
);

如何在开发人员阵列中访问???

1 个答案:

答案 0 :(得分:0)

您可以像这样访问开发人员数组:

$employees['Developers']

然后使用相关索引:

$employees['Developers']['Developer2']['name']

the language reference

中记录了这一点(与PHP中的几乎所有内容一样)