【发布时间】:2015-03-12 01:34:27
【问题描述】:
我正在尝试获取以下查询的结果
$users = DB::select("SELECT FIND_IN_SET('l','a,b,c,d') as Res");
当我这样做的时候
返回 $users;
这是我的 json
[{"Res":0}]
当我尝试decode 时,它显示错误
json_decode() expects parameter 1 to be string, array given
当我var_dump 时,我会变得像
array(1) { [0]=> object(stdClass)#773 (1) { ["Res"]=> int(0) } }
那么,我怎样才能得到'Res' 的结果?
【问题讨论】:
-
猜你需要做 $object[ 0 ]->res;因为您有一个数组,其中包含一个对象,该对象包含“res”属性中的字符串。
-
请edit 在此处添加遇到这些问题的代码的完整上下文。发布 Minimal, Complete, Verifiable Example 来证明您的问题将帮助您获得更好的答案。谢谢!
-
我的问题更新了,请看
标签: php arrays json decode encode