我有一个这样的数组:
echo "<pre>";
print_r($res_users);
/*
Array
(
[0] => stdClass Object
(
[position] => 1
[user] => stdClass Object
(
[full_name] => دکوراسیون
[is_private] => 1
[has_anonymous_profile_picture] =>
[byline] => 39.3k followers
[profile_pic_url] => https://scontent-frt3-1.cdninstagram.com/t51.2885-19/s150x150/11352072_817936521647202_201395223_a.jpg
[pk] => 1480272396
[follower_count] => 39326
[is_verified] =>
[mutual_followers_count] => 0
[username] => sajad.sobhi
)
)
)
我要做的就是从上面的数组中选择以下网址:
https://scontent-frt3-1.cdninstagram.com/t51.2885-19/s150x150/11352072_817936521647202_201395223_a.jpg
profile_pic_url
的值是多少。我怎么能得到它?
注意到这不起作用:
echo $res_users[0]['user']['profile_pic_url'];
答案 0 :(得分:2)
试试$res_users[0]->user->profile_pic_url
。因为$res_users[0]
是object
类型
答案 1 :(得分:1)
通过这种方式尝试 echo $ res_users [0] - &gt; user-&gt; profile_pic_url;