This is a tricky one (for me). I have an Array of data returned from a Twitter API call in an Array. I'm iterating the "Top 10 Trending" however cannot print the individual elements i.e. name, Below is the code I am using to get as far as I can:
$twitter = new TwitterOAuth($consumerKey,$consumerSecret,$oAuthToken,$oAuthSecret);
$locale = $twitter->get('https://api.twitter.com/1.1/trends/place.json?id=560472');
foreach($locale as $local)
{
print_r($local->trends);
}
This results in the below:
However I cannot access the individual elements through the Array at the top. Any suggestions?
Thank you in advance, Niall
$tweets = $local->trends;
echo $tweets[1]->name;
Or you can use foreach :
foreach ($local->trends as $trend)
{
echo $trend->name;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments