我編碼用戶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