Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在数组中包含多个键和值_Php_Arrays - Fatal编程技术网

Php 如何在数组中包含多个键和值

Php 如何在数组中包含多个键和值,php,arrays,Php,Arrays,我需要一些关于JSON post请求的帮助,我需要发布一个包含多个ID和值的字段数组。发布一个id和值是可行的,但我不知道如何在这个请求中包含多个字段id 这是我的密码: $appointment = $acuity->request('/appointments', array( 'method' => 'POST', 'data' => array( 'firstName' => 'Bob', 'lastName' => 'Burger', 'email' =&

我需要一些关于JSON post请求的帮助,我需要发布一个包含多个ID和值的字段数组。发布一个id和值是可行的,但我不知道如何在这个请求中包含多个字段id

这是我的密码:

$appointment = $acuity->request('/appointments', array(
'method' => 'POST',
'data' => array(
'firstName' => 'Bob',
'lastName' => 'Burger',
'email' => 'bob@example.org',
'datetime' => '2016-04-26T19:00:00-0700',
'appointmentTypeID' => 5020,
'fields' => array(
  array(
    'id' => 4,  // Custom field ID 4
    'value' => '1600 Pennsylvania Avenue',
    'id' => 5,  // Custom field ID 5
    'value' => '5550 Somewhere St.'
  )
)
)
));

我怀疑其目的是使用嵌套数组,如下所示:

'fields' => array(
  array(
    'id' => 4,  // Custom field ID 4
    'value' => '1600 Pennsylvania Avenue',
  ),
  array(
    'id' => 5,  // Custom field ID 5
    'value' => '5550 Somewhere St.'
  )
)

“字段”数组应该包含多个数组,它们本身包含“id”和“value”。所以在你的例子中有两个。