php中的多维数组[重复]

问题描述 投票:-6回答:1

这个问题在这里已有答案:

Array
(
    [users] => Array
        (
            [0] => Array
                (
                    [id] => 707865603789484032
                    [id_str] => 707865603789484032
                    [name] => Mintgroupation
                    [screen_name] => mintgroupation
                    [location] => 
                    [url] => 
                    [description] => 
                    [protected] => 
                    [followers_count] => 0
                    [friends_count] => 45
                    [listed_count] => 0
                    [created_at] => Thu Mar 10 09:48:06 +0000 2016
                    [favourites_count] => 0
                    [utc_offset] => 
                    [time_zone] => 
                    [geo_enabled] => 
                    [verified] => 
                    [statuses_count] => 0
                    [lang] => en
                    [contributors_enabled] => 
                    [is_translator] => 
                    [is_translation_enabled] => 
                    [profile_background_color] => F5F8FA
                    [profile_background_image_url] => 
                    [profile_background_image_url_https] => 
                    [profile_background_tile] => 
                    [profile_image_url] => http://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png
                    [profile_image_url_https] => https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png
                    [profile_link_color] => 2B7BB9
                    [profile_sidebar_border_color] => C0DEED
                    [profile_sidebar_fill_color] => DDEEF6
                    [profile_text_color] => 333333
                    [profile_use_background_image] => 1
                    [has_extended_profile] => 
                    [default_profile] => 1
                    [default_profile_image] => 1
                    [following] => 
                    [follow_request_sent] => 
                    [notifications] => 
                    [muting] => 
                    [blocking] => 
                    [blocked_by] => 
                )

            [1] => Array
                (
                    [id] => 707865725382369280
                    [id_str] => 707865725382369280
                    [name] => Mahmod Hassan

等等......

我想在变量中得到名称([name])

php html arrays twitter multidimensional-array
1个回答
1
投票

假设您在$ users变量中有用户数据。

$names = array_map(function($user){
              return $user['name'];
        }, $users);

现在,您所有用户都在$ names变量中命名

print_r($names);
© www.soinside.com 2019 - 2024. All rights reserved.