Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the first entry of a JSON object

Tags:

json

php

Facebook gives a JSON stream like this:

 "actions": [
    {
       "name": "Comment",
       "link": "http://www.facebook.com/100000335233539/posts/193845507303289"
    },
    {
       "name": "Like",
       "link": "http://www.facebook.com/100000335233539/posts/193845507303289"
    },
    {
       "name": "Read entire article",
       "link": "http://www.domain.tld/article/"
    }
 ],

I want to get the first of the three objects with:

$link = ($feeditem['actions']['link']);

But I always get only the last entry. How can I get the first one?

like image 910
Peleke Avatar asked Dec 06 '25 13:12

Peleke


1 Answers

This does the trick:

$actions[0]['link']
like image 173
seriousdev Avatar answered Dec 10 '25 11:12

seriousdev