dp0518 2013-11-09 15:00
浏览 50
已采纳

从位于变量Laravel eloquent查询结果中的无头数组中提取值

I do not know wheather it is a silly question or newer for you too. I am getting a search result in forms of an array in one complicated laravel eloquent query, which is stored in say "post".

When I am echoing this with

{{ $post }}

it is simply giving result like this

{"id":10,"post":"first","about":"first1","user_id":4,"likes":0,"points":2,"dcoms_count":0,"views":307,"created_at":"2013-11-01 19:52:41","updated_at":"2013-11-06 13:07:37"}

But I am unable to extract one single data from this table. like when I run

{{ $post->id }}

it is giving error output. can anyone help me with this ?

  • 写回答

1条回答 默认 最新

  • douwei2825 2013-11-09 15:07
    关注

    You're trying to access it like an object, this should be the correct way:

    {{ $post['id'] }}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?