我编码用户entred与json_encode testarea内容这里是它在MySQL如何storred(有 “AAA” 之后返回到线)json_decode(json_encode(索引数组))给出了NULL
{"content":"aaa
bbb"}
现在,当我从数据库中获取内容并尝试使用json_decode对其进行解码时,我得到NULL,而不是预期的。
什么wrrong? PHP中的错误?
编辑1:更多详情
$data =array('content'=>$textareaText);
$addres_insert = "INSERT INTO `rtable` (`data`) VALUES ('".json_encode($data)."');";
$rows = mysql_query($addres_insert);
然后获取内容
$query = "SELECT * FROM `rtable` WHERE id = '".$id."'";
$rows = mysql_query($query);
if ($rows){
$row = mysql_fetch_array($rows);
$res['data'] = json_decode($row['data']);//i tryed substr($row['data'],3) but didn't work
}
我们可以看到如何编码/解码这阵? – Tom
它可能是utf8。几乎相同的讨论检查http://stackoverflow.com/questions/689185/json-decode-returns-null-php。 – Kerhong