Reputation: 4003
I've tried the following:
<?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);
?>
and I get the following output:
[{"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":""}]
The data is correct but as you can see not readable. What can I do to solve this issue? It should show arabic words not what it is showing now
thanks,
Upvotes: 0
Views: 1921
Reputation: 2414
You need a special encoding to have readable json result of arabic character (unicode).
You can specify otherwise with JSON_UNESCAPED_UNICODE PHP 5.4 or later.
json_encode('yourarabiccharacters', JSON_UNESCAPED_UNICODE);
Upvotes: 4