How to remove backslash on json_encode() function?

前端 未结 10 1856
逝去的感伤
逝去的感伤 2020-12-03 04:42

How to remove the (\\)backslash on a string? when using echo json_encode() ?

For example:



        
10条回答
  •  忘掉有多难
    2020-12-03 05:21

    If you using PHP 5.2, json_encode just expect only 1 parameter when call it. This is an alternative to unescape slash of json values:

    stripslashes(json_encode($array))
    

    Don't use it if your data is complicated.

提交回复
热议问题