Tag Archives: Array to string conversion

[PHP] Array to string conversion error when sending data in post

When using curl to pass post data, if the data field is an array, an error will be reported Array to string conversion

When calling curl_setopt_array($curl, $options);

Call curl_setopt($ch, CURLOPT_POSTFIELDS, $data)

Errors may be reported in these two places, the solution is to process the data array

http_build_query($data)