我有一個數組是這樣的:如何在存在對象的情況下訪問數組的項目?
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'];
Downvoter請留下評論並解釋我的問題出了什麼問題? – stack
'$ res_users [0] - > user-> profile_pic_url;'確保你知道數組和對象的區別 –