How to json_encode array with french accents?

后端 未结 7 2311
离开以前
离开以前 2020-12-05 13:58

I have an array item with a French accent ([WIPDescription] => Recette Soupe à lOignon Sans Boeuf US). The data is being properly pulled from the database (mysql).

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 14:27

    Another solution would be to use htmlentities or utf8_encode before using json_encode to pass the encoded char

    like this:

       $array = array('myvalue' => utf8_encode('ééàà'));
       return json_encode($array);
    

    Or using htmlentities :

       $array = array('myvalue' => htmlentities('ééàà'));
       return json_encode($array);
    

提交回复
热议问题