Php 将数组转换为具有所有相同的键
我需要数组的所有键都相同。我知道用php他们做不到,但我正在尝试向soap发送一个数组 我的数组看起来像这样Php 将数组转换为具有所有相同的键,php,Php,我需要数组的所有键都相同。我知道用php他们做不到,但我正在尝试向soap发送一个数组 我的数组看起来像这样 array( [0] => Array ( [SKU] => Special Day [Description] => Special Day [Quantity] => 3 ) [1] => Array ( [SKU] => The Legend Co
array(
[0] => Array
(
[SKU] => Special Day
[Description] => Special Day
[Quantity] => 3
)
[1] => Array
(
[SKU] => The Legend Continues
[Description] => The Legend Continues
[Quantity] => 7
)
[2] => Array
(
[SKU] => Blank Inside
[Description] => Blank Inside
[Quantity] => 1
)
)
我需要这个
$auth = array(
'Shipment' => array(
'Items' => array(
'Item'=> Array
(
[SKU] => Special Day
[Description] => Special Day
[Quantity] => 3
)
'Item' => Array
(
[SKU] => The Legend Continues
[Description] => The Legend Continues
[Quantity] => 7
)
'Item' => Array
(
[SKU] => Blank Inside
[Description] => Blank Inside
[Quantity] => 1
)
)
)
我怎样才能将构成阵列的循环转化为我所需要的
我现在用它来制作阵列
while (wpsc_have_cart_items()) : wpsc_the_cart_item();
$items[] = array(
'SKU' => wpsc_cart_item_name(),
'Description' => wpsc_cart_item_name(),
'Quantity' => wpsc_cart_item_quantity()
);
endwhile;
我们不能对数组使用相同的键
Item
,它应该是Item-1、Item-2、Item-3
etcI我不熟悉SOAP编程,但我怀疑它需要这样做。这在PHP中是不可能的。在将其发送到SOAP之前,是否要将其转换为XML。是的,我想我需要这样做。检查,它提供了一些方法。