PHP json_encode()表情符号图标和字母作为数组键值

时间:2016-08-15 19:28:57

标签: php

我有一个数组,其中包含表情符号图标和文本字符串作为键值,类似于以下内容:

$a=array(
   " hi no 1"=> "  this is a test",
   " hi no 1"=> "  this is a test",
   " hi no 1"=> "  this is a test",
   " hi no 1"=> "  this is a test",
    " no 3" => array("this is a test"," test"),
    " no 3" => array("this is a test"," test"),
    " no 3" => array("this is a test"," test"),
    " no 3" => array("this is a test"," test"),
    " no 3" => array("this is a test"," test"),
);

问题是file_put_contents($filepath,json_encode($a));将空数组保存到数据库中。你会建议一个解决方案吗?

1 个答案:

答案 0 :(得分:2)

你可以尝试

file_put_contents($filepath,json_encode($a, JSON_UNESCAPED_UNICODE));

看看是否有效,因为表情符号是unicode,我认为可以解决它。