I need to send Json with one of the parameters being an array . The following code works perfectly .
$html = $client->post($url,
['json'=>[ 'requestData'=>
[
'sessionID'=>'261-7306141-0539957'
]
,
'productTargets'=>
[
[ 'ProductID'=>$data[0] ],
[ 'ProductID'=>$data[1] ],
[ 'ProductID'=>$data[2] ],
[ 'ProductID'=>$data[3] ],
[ 'ProductID'=>$data[4] ],
],
] ]
);
As you can see I am manually entering data[0],data[1],data[2] in productTargets . I need to send multiple like 100's of 'ProductID' object . I tried using
json_encode( [ [ 'ProductID'=>$data[0] ],
['ProductID'=>$data[2] ],
['ProductID'=>$data[3] ],
['ProductID'=>$data[4] ], ]
)
But it's not working . How do I send the data