Getting Undefined offset: 0 retrieving ..->entities->urls[0]->url;


I am using the API as shown here and have a foreach loop to retrieve to display each tweet ($latesttweets as $tweet).

Right now, when I do a $url_in_text = $tweet->entities->urls[0]->url, it gives me a Notice: Undefined offset: 0 and Notice: Trying to get property of non-object on the next line. What's weird is I am able to retrieve the value and echo it out ( without a notice). To sum it up, I'm getting a notice whenever a line containing ..->urls[0]->.. is used but the code works perfectly without a problem when retrieving it.

I'm using WordPress on PHP 5.4 and MAMP.

I've tried a lot of things to remove the notice like doing a isset() check (which works), but what is the real problem here?