我有一个数组,其中包含表情符号图标和文本字符串作为键值,类似于以下内容:
$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));
将空数组保存到数据库中。你会建议一个解决方案吗?
答案 0 :(得分:2)
你可以尝试
file_put_contents($filepath,json_encode($a, JSON_UNESCAPED_UNICODE));
看看是否有效,因为表情符号是unicode,我认为可以解决它。