Skip to content

Instantly share code, notes, and snippets.

@MahdiMajidzadeh
Last active May 5, 2021 11:09
Show Gist options
  • Save MahdiMajidzadeh/88407f4c33a294cae29ed1493332d7c0 to your computer and use it in GitHub Desktop.
Save MahdiMajidzadeh/88407f4c33a294cae29ed1493332d7c0 to your computer and use it in GitHub Desktop.
Fix JSON Persian character in php
// in php >= 5.4
echo json_encode($myarr,JSON_UNESCAPED_UNICODE);
// in php <= 5.3
header('Content-Type: application/json; charset=utf-8');
function jsonRemoveUnicodeSequences($array) {
return preg_replace("/\\\\\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode($array));
}
@parsasamandi
Copy link

Great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment