将数组转换为具有所有相同的键

时间:2012-10-20 06:23:15

标签: php

我需要一个数组的所有键都一样。我知道他们不能使用php,但我正在尝试将数组发送给soap。

我的阵列看起来像这样。

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;

0 个答案:

没有答案