我想推动这个:
"serialNumber" => $serial,
$ postArray和
的内部产品数组"note" => array(
"text" => $note
),
在bookingDate Inside $ postArray之前。
$postArray = array(
"reservationDate" => $timeData,
"emailLanguageCode" => "it_it",
"shipToCode" => $_POST['ship'],
"customer" => array(
"firstName" => $_POST['firstName'],
"lastName" => $_POST['lastName'],
"emailId" => $_POST['emailId'],
"phoneNumber" => $_POST['phoneNumber'],
"address" => array(
"addressLine1" => $_POST['addressLine1'],
"city" => $_POST['city'],
"state" => $_POST['state'],
"country" => $_POST['country'],
"postalCode" => $_POST['postalCode']
)
),
"product" => array(
"productCode" => $_POST['productCode'],
"issueReported" => $_POST['issueReported']
)
);
结果我想:
$postArray = array(
"note" => array(
"text" => $note
),
"reservationDate" => $timeData,
"emailLanguageCode" => "it_it",
"shipToCode" => $_POST['ship'],
"customer" => array(
"firstName" => $_POST['firstName'],
"lastName" => $_POST['lastName'],
"emailId" => $_POST['emailId'],
"phoneNumber" => $_POST['phoneNumber'],
"address" => array(
"addressLine1" => $_POST['addressLine1'],
"city" => $_POST['city'],
"state" => $_POST['state'],
"country" => $_POST['country'],
"postalCode" => $_POST['postalCode']
)
),
"product" => array(
"serialNumber" => $serial,
"productCode" => $_POST['productCode'],
"issueReported" => $_POST['issueReported']
)
);
我试过了:
array_push($postArray["product"][],$numeroSerie);
请帮忙。
答案 0 :(得分:0)
只需简单地执行此操作
$postArray['product']['serialNumber'] = $serial;
答案 1 :(得分:0)
使用array_merge
后,在产品数组中创建所需数组的第一个数组$postArray1 = array(
"note" => array(
"text" =>15
));
$postArray = array(
"reservationDate" =>1,
"emailLanguageCode" => 2,
"shipToCode" => 3,
"customer" => array(
"firstName" => 4,
"lastName" => 5,
"emailId" => 6,
"phoneNumber" => 7,
"address" => array(
"addressLine1" => 8,
"city" =>9,
"state" => 10,
"country" => 11,
"postalCode" => 12
)
),
"product" => array(
"productCode" => 13,
"issueReported" => 14
)
);
array_merge($postArray1,$postArray);
答案 2 :(得分:0)
这两行,
$postArray['product'] = $serial + $postArray['product'];
$postArray = $numeroSerie + $postArray ;
就是这样,
+
运算符给出数组和offcourse的并集将满足您的要求。
试一试,这样可行。
答案 3 :(得分:0)
非常简单,添加这两行代码:
// insert "serialNumber" into "product" array
$postArray['product']['serialNumber'] = $serial;
// insert "note" into begining array element
$postArray = array('note'=>array("text" => $note))+$postArray;
答案 4 :(得分:0)
你会尝试这个我认为它的工作正常。
$data=array("note" => array("text" => $note));
$postArray= array_merge($data,$postArray);
$postArray["product"]=array_merge(array("serialNumber"=> $serial),$postArray["product"]);