json_decode() 期望参数 1 是字符串,给定数组
导致代码中出现此错误的原因是什么?
$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
错误:
erro: json_decode() expects parameter 1 to be string, array given: Line Number: 167
更新:
如果我使用 代替 ,我的输出是这样的:json_encode
json_decode
[{"guide":["\u0633\u06cc\u062f \u0633\u0639\u06cc\u062f \u062f\u0627\u062f\u0627\u0634\u0632\u0627\u062f\u0647"]},{"guide":["\u0633\u06cc\u062f \u0633\u0639\u06cc\u062f \u062f\u0627\u062f\u0627\u0634\u0632\u0627\u062f\u0647"]},{"guide":null}]
它们是波斯语单词。