You've successfully subscribed to Nicholas Workshop
Great! Next, complete checkout for full access to Nicholas Workshop
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

PHP使用Json中文Unicode亂碼解决方法

Nicholas Wong
Nicholas Wong
$string = '你好嗎';  
echo json_encode($string); //Output "u4f60u597du55ce"  
echo preg_replace("#u([0-9a-f]+)#ie", "iconv(‘UCS-2’, ‘UTF-8’, pack(‘H4’, ‘1’))", json_encode($string)); // Output "你好嗎"  
Unsorted

Nicholas Wong

Fullstack software engineer with strong background in computer science and extensive experience in software engineering and architecture. Studied in NYU, worked in Yahoo, Rakuten and Manulife.