2013-11-09 15:00
浏览 48

从位于变量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'] }}
    打赏 评论

相关推荐 更多相似问题