【发布时间】:2017-03-10 07:12:43
【问题描述】:
我有一个这样的数组:
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
)
)
)
我要做的就是从上面的数组中选择以下 URL:
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'];
【问题讨论】:
-
反对者请发表评论并解释我的问题有什么问题?
-
$res_users[0]->user->profile_pic_url;确保你知道数组和对象之间的区别