PHP json_encode json_decode UTF-8

前端 未结 10 852
温柔的废话
温柔的废话 2020-12-01 07:45

How can I save a json-encoded string with international characters to the databse and then parse the decoded string in the browser?



        
10条回答
  •  孤城傲影
    2020-12-01 08:32

    Work for me :)

    function jsonEncodeArray( $array ){
        array_walk_recursive( $array, function(&$item) { 
           $item = utf8_encode( $item ); 
        });
        return json_encode( $array );
    }
    

提交回复
热议问题