如何从json输出中删除反斜杠(PHP)

最后发布: 2019-11-12 06:10:52


问题

json范例

我在这里有json输出

"[id_service\":\"3\",\"reference_number\":\"\",\"tracking_number\":\"RJC-0000-0001\",\"kd_inbound\":\"INB-1000-0001\",\"tgl_inbound\":\"2019-11-08 00:00:00\",\"status_inb\":\"1\"},{\"id_service\":\"3\",\"reference_number\":\"\",\"kd_outbag\":\"BAG-1468-0001\",\"tanggal_outbag\":\"2019-11-08 00:00:00\",\"status_outbag\":\"1\"},{\"id_service\":\"3\",\"reference_number\":\"\",\"kd_outbound\":\"OTB-1826-0001\",\"tgl_outbound\":\"2019-11-08 14:04:00\",\"status_otb\":\"1\"},{\"id_service\":\"3\",\"reference_number\":\"\",\"tracking_number\":\"RJC-0000-0001\",\"kd_indes\":\"INB-DES-56730001\",\"tgl_indes\":\"2019-11-08 14:07:30\",\"status_indes\":\"1\"},,,{\"id_service\":\"3\",\"reference_number\":\"\",\"tracking_number\":\"RJC-0000-0001\",\"tgl_status\":\"2019-11-07 17:06:43\",\"status\":\"Consignee Unknown\"},{\"id_service\":\"3\",\"reference_number\":\"\",\"tracking_number\":\"RJC-0000-0001\",\"tgl_status\":\"2019-11-08 10:29:07\"\"status\":\"Closed\"]"

如何删除反斜杠

public function awb_get() {
    $id = $this->get('tracking_number');
    $arr= array(      
      $this->M_tarif->tampil_status_inbound($id),
      $this->M_tarif->tampil_status_otboundbag($id),
      $this->M_tarif->tampil_status_otboundori($id),
      $this->M_tarif->tampil_status_indes($id),
      $this->M_tarif->tampil_status_outdes($id),
      $this->M_tarif->tampil_status_runsheet($id),
      $this->M_tarif->tampil_db_service_status($id)
    );
    $result = str_replace(array('[',']','\n'), '',htmlspecialchars(json_encode($arr), ENT_NOQUOTES));
    $str = preg_replace('/\\\"/',"\"", $result);
    $json = '[';
    $json .= substr($str, 2,-1); 
    $json .= ']';
    $jsonData = preg_replace("/,(?!.*,)/", "", $json);
    $this->response($jsonData, 200);
}

如何删除json上的blackslases? 我附上以下创建的代码

php arrays json string object