-3

I have an array like this:

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
                )

        )
)

All I'm trying to do is selecting following URL from array above:

https://scontent-frt3-1.cdninstagram.com/t51.2885-19/s150x150/11352072_817936521647202_201395223_a.jpg

Which is the value of profile_pic_url. How can I get that?


Noted that this doesn't work:

echo $res_users[0]['user']['profile_pic_url'];
stack
  • 10,280
  • 19
  • 65
  • 117

2 Answers2

2

Try $res_users[0]->user->profile_pic_url. Because $res_users[0] is object type

Saumini Navaratnam
  • 8,439
  • 3
  • 42
  • 70
1

Try it by this way echo $res_users[0]->user->profile_pic_url;

Suman Biswas
  • 853
  • 10
  • 19