我尝试了以下方法:
<?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":""}]
数据是正确的,但你可以看到不可读。我能做些什么来解决这个问题?它应该显示阿拉伯语单词而不是现在显示的内容
谢谢,