PHPで配列の取得方法が分からないため教えていただきたく。
以下に張り付けた配列内にあります、
["profile_image_url_https"]を取得したいのですがうまくいきません。
PHP
1array(2) 2{ 3 ["statuses"]=> array(1) 4 { 5 [0]=> array(24) 6 { 7 ["created_at"]=> string(30) "Sat Nov 17 00:29:37 +0000 2018" 8 ["id"]=> int(1063589943115751424) 9 ["id_str"]=> string(19) "1063589943115751424" 10 ["text"]=> string(104) "#モンハン女子" 11 ["truncated"]=> bool(false) 12 ["entities"]=> array(4) 13 { 14 ["hashtags"]=> array(1) 15 { 16 [0]=> array(2) 17 { 18 ["text"]=> string(18) "モンハン女子" 19 ["indices"]=> array(2) 20 { 21 [0]=> int(35) 22 [1]=> int(42) 23 } 24 } 25 } 26 ["symbols"]=> array(0) { } 27 ["user_mentions"]=> array(0) { } 28 ["urls"]=> array(0) { } 29 } 30 ["metadata"]=> array(2) 31 { 32 ["iso_language_code"]=> string(2) "ja" 33 ["result_type"]=> string(6) "recent" 34 } 35 ["source"]=> string(66) "Twitter Web Client" 36 ["in_reply_to_status_id"]=> NULL 37 ["in_reply_to_status_id_str"]=> NULL 38 ["in_reply_to_user_id"]=> NULL 39 ["in_reply_to_user_id_str"]=> NULL 40 ["in_reply_to_screen_name"]=> NULL 41 ["user"]=> array(42) 42 { 43 ["id"]=> int(1059756301494837248) 44 ["id_str"]=> string(19) "1059756301494837248" 45 ["name"]=> string(30) "やすぅ" 46 ["screen_name"]=> string(10) "234908yasu" 47 ["location"]=> string(0) "" 48 ["description"]=> string(37) "????" 49 ["url"]=> NULL 50 ["entities"]=> array(1) 51 { 52 ["description"]=> array(1) 53 { 54 ["urls"]=> array(0) { } 55 } 56 } 57 ["protected"]=> bool(false) 58 ["followers_count"]=> int(4) 59 ["friends_count"]=> int(1) 60 ["listed_count"]=> int(0) 61 ["created_at"]=> string(30) "Tue Nov 06 10:36:06 +0000 2018" 62 ["favourites_count"]=> int(0) 63 ["utc_offset"]=> NULL 64 ["time_zone"]=> NULL 65 ["geo_enabled"]=> bool(false) 66 ["verified"]=> bool(false) 67 ["statuses_count"]=> int(57) 68 ["lang"]=> string(2) "ja" 69 ["contributors_enabled"]=> bool(false) 70 ["is_translator"]=> bool(false) 71 ["is_translation_enabled"]=> bool(false) 72 ["profile_background_color"]=> string(6) "F5F8FA" 73 ["profile_background_image_url"]=> NULL 74 ["profile_background_image_url_https"]=> NULL 75 ["profile_background_tile"]=> bool(false) 76 ["profile_image_url"]=> string(75) "http://pbs.twimg.com/profile_images/1061573140357177344/wv7CuFGe_normal.jpg" 77 ["profile_image_url_https"]=> string(76) "https://pbs.twimg.com/profile_images/1061573140357177344/wv7CuFGe_normal.jpg" 78 ["profile_banner_url"]=> string(68) "https://pbs.twimg.com/profile_banners/1059756301494837248/1541933750" 79 ["profile_link_color"]=> string(6) "1DA1F2" 80 ["profile_sidebar_border_color"]=> string(6) "C0DEED" 81 ["profile_sidebar_fill_color"]=> string(6) "DDEEF6" 82 ["profile_text_color"]=> string(6) "333333" 83 ["profile_use_background_image"]=> bool(true) 84 ["has_extended_profile"]=> bool(false) 85 ["default_profile"]=> bool(true) 86 ["default_profile_image"]=> bool(false) 87 ["following"]=> bool(false) 88 ["follow_request_sent"]=> bool(false) 89 ["notifications"]=> bool(false) 90 ["translator_type"]=> string(4) "none" 91 } 92 ["geo"]=> NULL 93 ["coordinates"]=> NULL 94 ["place"]=> NULL 95 ["contributors"]=> NULL 96 ["is_quote_status"]=> bool(false) 97 ["retweet_count"]=> int(0) 98 ["favorite_count"]=> int(0) 99 ["favorited"]=> bool(false) 100 ["retweeted"]=> bool(false) 101 ["lang"]=> string(2) "ja" 102 } 103 } 104 ["search_metadata"]=> array(9) 105 { 106 ["completed_in"]=> float(0.019) 107 ["max_id"]=> int(1063589943115751424) 108 ["max_id_str"]=> string(19) "1063589943115751424" 109 ["next_results"]=> string(215) "?max_id=1063589943115751423&q=%23%E3%83%9D%E3%83%BC%E3%83%88%E3%83%AC%E3%83%BC%E3%83%88%20-RT%20since%3A2018-11-16_00%3A00%3A00_JST%20until%3A2018-11-17_23%3A59%3A59_JST&count=1&include_entities=1&result_type=recent" 110 ["query"]=> string(133) "%23%E3%83%9D%E3%83%BC%E3%83%88%E3%83%AC%E3%83%BC%E3%83%88+-RT+since%3A2018-11-16_00%3A00%3A00_JST+until%3A2018-11-17_23%3A59%3A59_JST" 111 ["refresh_url"]=> string(209) "?since_id=1063589943115751424&q=%23%E3%83%9D%E3%83%BC%E3%83%88%E3%83%AC%E3%83%BC%E3%83%88%20-RT%20since%3A2018-11-16_00%3A00%3A00_JST%20until%3A2018-11-17_23%3A59%3A59_JST&result_type=recent&include_entities=1" 112 ["count"]=> int(1) 113 ["since_id"]=> int(0) 114 ["since_id_str"]=> string(1) "0" 115 } 116}
試したのはこのような形です。
PHP
1foreach ($tweets_arr["statuses"] as $d) 2{ 3 echo $d["source"]."<br>"; ←取得できる① 4 foreach ($d["user"] as $e) 5 { 6 echo $e->profile_image_url_https; ←取得できない② 7 echo $e["profile_image_url_https"]; ←取得できない③ 8 } 9}
教えていただけますでしょうか。
よろしくお願いいたします。
配列のご提示は良いのですが改行もインデントもないものですし、var_dumpよりもvar_exportの方が再現確認や検証を行いやすい形となりますので、ご調整願えますか?配列で大事なのは階層なので、その階層が分かりづらいと欲しい情報を正しく取れません

回答2件
あなたの回答
tips
プレビュー