是什么导致我的代码错误?
$query = $this->db->query("SELECT * FROM tour_foreign ORDER BY id desc");
$data = array();
foreach ($query->result() as $row)
$data[] = array('guide' => $row->guide);
echo json_decode($data); //Line 167
Run Code Online (Sandbox Code Playgroud)
错误:
erro: json_decode() expects parameter 1 to be string, array given: Line Number: 167
Run Code Online (Sandbox Code Playgroud)
更新:
如果使用json_encode
,而不是json_decode
我的输出是这样的:
[{"guide":["\u0633\u06cc\u062f \u0633\u0639\u06cc\u062f \u062f\u0627\u062f\u0627\u0634\u0632\u0627\u062f\u0647"]},{"guide":["\u0633\u06c??c\u062f \u0633\u0639\u06cc\u062f \u062f\u0627\u062f\u0627\u0634\u0632\u0627\u062f\u0647"]},{"guide":null}]
Run Code Online (Sandbox Code Playgroud)
他们是波斯语.
Kar*_*eem 14
您的解码未设置为true.如果您无权将源设置为true.下面的代码将为您解决.
$WorkingArray = json_decode(json_encode($data),true);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
103044 次 |
最近记录: |