在json_encode时添加反斜杠

时间:2016-08-24 06:11:54

标签: json

     ------------------------  START   ------------------------    

{"oxitrxid":"00000175052408201611","msg":"0|{\"ticket_ref_no\":\"ETS0S68691463\",\"ticket_id\":\"16907\",\"userid\":\"7002\",\"track_id\":\"57bd3908a8a9416907\"}","mtrxid":"BOS0851161472018696","paidamt":"950.00","trxstatus":"0","trxmsg":"Success","othervals":"{\"ticket_ref_no\":\"ETS0S68691463\",\"ticket_id\":\"16907\",\"userid\":\"7002\",\"track_id\":\"57bd3908a8a9416907\"}","omtid":"HR010100203"} 

  ------------------------  END   ------------------------ 

我想从上面编码的数组中删除正斜杠, 我试图使用JSON_UNESCAPED_SLASHES 我试图使用str_replace 但没有什么能取代它。

$a = array 
  (
        "oxitrxid" => '00000175052408201611',
        "msg" =>  '0|{"ticket_ref_no":"ETS0S68691463","ticket_id":"16907","userid":"7002",
"track_id":"57bd3908a8a9416907"}',
        "mtrxid" => 'BOS0851161472018696',
        "paidamt" => '950.00',
        "trxstatus" => '0',
        "trxmsg" => 'Success',
        "othervals" => '{"ticket_ref_no":"ETS0S68691463","ticket_id":"16907","userid":"7002","track_id":"57bd3908a8a9416907"}'
    );
$array_response = array_map('trim',$a);
 $b             = json_encode($array_response,JSON_UNESCAPED_SLASHES);

0 个答案:

没有答案