PHP CURL不适用于多维数组

PHP CURL不适用于多维数组,php,arrays,curl,Php,Arrays,Curl,我有一个PHP脚本,可以通过CURL更新联系人详细信息,它需要做2次更新,一次更新到客户端,一次更新到联系人。客户机位工作正常,但联系人只是用空格更新数据库,它不会留下值,它会完全清除这些值,有人知道原因吗 谢谢 代码如下: itemid和contactid在脚本中声明,工作正常 //Update Client $name = "test2 test2"; $address1 = "my house"; $city = "my city"; $state = "my state"; $posta

我有一个PHP脚本,可以通过CURL更新联系人详细信息,它需要做2次更新,一次更新到客户端,一次更新到联系人。客户机位工作正常,但联系人只是用空格更新数据库,它不会留下值,它会完全清除这些值,有人知道原因吗

谢谢

代码如下: itemid和contactid在脚本中声明,工作正常

//Update Client
$name = "test2 test2";
$address1 = "my house";
$city = "my city";
$state = "my state";
$postal_code = "NE25 8RU";
$work_phone = "01234567";
$first_name = "test2";
$last_name = "test2";
$email = "test@test.com";
$url = urlencode("https://myurl.co.uk/api/v1/clients/$itemid");
$encoded_url = urlencode($url);
$after_encoded_url = str_replace("%2F", "/", $url);
$after_encoded_url2 = str_replace("%3A", ":", $after_encoded_url);
$after_encoded_url3 = str_replace("%3Cbr+/%3E", "/", $after_encoded_url2);
$curl = curl_init(); 

    if (!$curl) {
        die("Couldn't initialize a cURL handle"); 
    }
$headers = [
'Content-Type: application/json',
'X-Requested-With: XMLHttpRequest',
'X-Ninja-Token:token',
];
$cid = (int)$contactid;
$postdata3 = array(
"name" => $name,
"address1" => $address1,
"city" => $city,
"state" => $state,
"postal_code" => $postal_code,
"work_phone" => $work_phone,
"contacts" => array(array(
    "id" => $cid,
    "client_id" => $itemid,
    "first_name" => $first_name,
    "last_name" => $last_name,
    "email" => $email,
    "phone" => $work_phone
))
);


$postdata = json_encode($postdata3);


echo $after_encoded_url3;
    // Set the file URL to fetch through cURL
    curl_setopt($curl, CURLOPT_URL, $after_encoded_url3);

    // Set a different user agent string (Googlebot)
    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT     5.0)'); 

    // Follow redirects, if any
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 

    // Fail the cURL request if response code = 400 (like 404 errors) 
    curl_setopt($curl, CURLOPT_FAILONERROR, true); 

    // Return the actual result of the curl result instead of success code
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

    // Wait for 10 seconds to connect, set 0 to wait indefinitely
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);

    // Execute the cURL request for a maximum of 50 seconds
    curl_setopt($curl, CURLOPT_TIMEOUT, 50);

            // Execute the cURL request for a maximum of 50 seconds
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");

                    // Execute the cURL request for a maximum of 50 seconds
    curl_setopt($curl, CURLOPT_POST, "PUT === 'POST' ? 1 : 0");
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata3);

    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

    // Do not check the SSL certificates
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 

    // Fetch the URL and save the content in $html variable
    $html = curl_exec($curl); 

    // Check if any error has occurred 
    if (curl_errno($curl)) 
    {
        echo 'cURL error: ' . curl_error($curl); 
    } 
    else 
    { 
        // cURL executed successfully

        return $html;
    }

    // close cURL resource to free up system resources
    curl_close($curl);

这不是因为这里有数组:
“联系人”=>数组(
)吗?这不是因为这里有数组:
“联系人”=>数组(
)吗?