mercredi 30 décembre 2015

Get Value in Deep Object/Array

I'm using the Twitter Api PHP library which returns the following object fine in my controller:

$tw_trends = $this->twitter->trends();

[
    {
        "trends": [
            {
                "name": "Bill Cosby",
                "url": "http://twitter.com/search?q=%22Bill+Cosby%22",
                "promoted_content": null,
                "query": "%22Bill+Cosby%22",
                "tweet_volume": 229907
            },
            ...

However, when I pass the $tw_trends to my view and try and do the following foreach, I get an error. How can I access the name value in the above object?

@foreach ($tw_trends as $trend)
    <ul>
        <li>
            {{ $trend->name }}
        </li>
    </ul>
@endforeach

Error:

Undefined property: stdClass::$name



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1mqlnd2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire