PHP Curl can only pass an array of one-dimensional array, if you want to pass a multidimensional array: two methods:
1. Convert to JSON in transfer
2.
//a request to simulate a post via curl;functionSenddatabycurl ($url,$data=Array()){ //to escape a space $url=Str_replace(', ' + ',$url); $ch=Curl_init (); //setting options, including URLscurl_setopt ($ch, Curlopt_url, "$url"); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, curlopt_timeout,3);//define timeout 3 seconds//Post datacurl_setopt ($ch, Curlopt_post, 1); //Add the post variable to thecurl_setopt ($ch, Curlopt_postfields,Http_build_query($data));//the required array is processed with the http_bulid_query () function, OK//execute and get the contents of the URL address $output= Curl_exec ($ch); $errorCode= Curl_errno ($ch); //releasing the curl handleCurl_close ($ch); if(0!==$errorCode) { return false; } return $output;}
$post of Curl passing multidimensional arrays