mardi 14 septembre 2021

How prevent slashes on URL during json_encode() - PHP? [duplicate]

I'm trying to construct a clean json with no slashes, but I kept getting them. I've been creating array, and encode it like so json_encode($data); all the time. It always works, but this time I got a lot slashes.

$data                                = [];
$data['input']['upload-destination'] = env('CONTROLLER_URL').'/controller/v1/'.$nodeId.'/pkt_capture/upload?port='.$interface;
$data['input']['upload-username']    = 'code-ro@site.com';
$data['input']['upload-password']    = '123';

$url           = $SERVICE_URL.'/restconf/data/interfaces-state/interface=0%2F'.$interface.'/packet-capture-start';
$data          = json_encode($data);
$result        = HTTP::post($url, $data);


//dd(get_defined_vars());

enter image description here

How do I avoid that ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire