0
我已經試過如下:JSON編碼PHP
<?php
header('Content-Type: text/html; charset=utf-8');
$conn = mysql_connect("localhost", "dsds", "dsds");
mysql_select_db('dsdasds');
$sqlquery = "select * from discounts";
mysql_set_charset('utf8');
$result = mysql_query($sqlquery, $conn);
if(! $result)
{
die('Could not get data: ' . mysql_error());
}
/*
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo $row['name'];
}
*/
$dataArray = array();
while($r = mysql_fetch_array($result))
{
$dataArray[] = $r;
}
print json_encode($dataArray);
?>
,我得到下面的輸出:
[{"0":"\u0628\u0631\u0628\u0631\u064a ","name":"\u0628\u0631\u0628\u0631\u064a ","1":"55","rate":"55","2":"\u0627\u0644\u0631\u0627\u0634\u062f ","location":"\u0627\u0644\u0631\u0627\u0634\u062f ","3":"68","id":"68","4":"\u0627\u0644\u062e\u0628\u0631","city":"\u0627\u0644\u062e\u0628\u0631","5":"","duration":"","6":"","category":""}]
的數據是正確的,但你可以看到無法讀取。我能做些什麼來解決這個問題?它應該顯示阿拉伯語詞彙不是它現在顯示
感謝,
現在我什麼都看不到。 –
嘗試將您的標題更改爲標題('Content-Type:application/json; charset = utf-8''); – legrandviking
不要怪怪的字符 –