dp0518 2013-11-09 07: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 07:07
    关注

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

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部