0
 $response="بسم الله الرحمن الرحيم";       
 $string='{

    "something": "'.$response.'"
}';

Please give me a solution to json_decode above string. When I try json_decode($string, true, JSON_UNESCAPED_UNICODE); result is null

Shafeeq
  • 467
  • 7
  • 17
Shamnad K M
  • 35
  • 2
  • 10
  • What kind of JSON wrapper API around PDO is that? Just seems to be substituting SQL injection for JSON injection. – deceze Mar 27 '14 at 09:50

2 Answers2

1

Most probably json_decode have problem with arabic charactor. The arabic text should convert to utf-8.if after decode also the arabic text coming properly hope you will get the result.

@header('Content-Type: text/html; charset=utf-8');


$response="بسم الله الرحمن الرحيم";  

$response= iconv('windows-1256', 'utf-8', ($response)); 
$string='{

"something": "'.$response.'"
}';

echo "Before Decode :";
var_dump($string);

echo "After Decode :";
$json=json_decode($string);
var_dump($json);
Shafeeq
  • 467
  • 7
  • 17
0

You will have to change the charset of your DBMS to one that suits your needs.

Assuming your are using MySQL and PHPMyAdmin, you have to go to your PHPMyAdmin page and choose an appropriate charset. The default is, as far as I remember, UTF-8.

Patrick Reck
  • 11,246
  • 11
  • 53
  • 86