如何组合多维数组



我有下面的数组,我真的很纠结如何将定价数据添加到相应的产品数据中,这样每个数字索引就有一个数组。

  [Product] => Array
        (
            [0] => Array
                (
                    [Title] => Rent: Filmed Live on Broadway
                    [UPC] => 043396297913
                    [ASIN] => B001LMAKAG
                    [SalesRank] => 12429
                    [ImageURL] => http://ecx.images-amazon.com/images/I/51rzFLo7EML._SL200_.jpg
                    [ProductGroup] => DVD
                    [Publisher] => Sony Pictures Home Entertainment
                    [NumberOfDiscs] => 1
                )
            [1] => Array
                (
                    [Title] => Scrooged
                    [UPC] => 097363205425
                    [ASIN] => 6305609772
                    [SalesRank] => 308636
                    [ImageURL] => http://ecx.images-amazon.com/images/I/51BqfhI7NaL._SL200_.jpg
                    [ProductGroup] => DVD
                    [Publisher] => Paramount
                    [NumberOfDiscs] => 1
                )
            [2] => Array
                (
                    [Title] => Upstairs Downstairs: Season 2
                    [UPC] => 883929253753
                    [ASIN] => B0090XUARQ
                    [SalesRank] => 23167
                    [ImageURL] => http://ecx.images-amazon.com/images/I/51O-STwE1SL._SL200_.jpg
                    [ProductGroup] => DVD
                    [Publisher] => BBC Home Entertainment
                    [NumberOfDiscs] => 2
                )
            [3] => Array
                (
                    [Title] => Junction Boys
                    [UPC] => 796019795210
                    [ASIN] => B000FVR1T2
                    [SalesRank] => 32220
                    [ImageURL] => http://ecx.images-amazon.com/images/I/41151H2xalL._SL200_.jpg
                    [ProductGroup] => DVD
                    [Publisher] => Genius
                    [NumberOfDiscs] => 1
                )
            [4] => Array
                (
                    [Title] => 20-Film Horror: The Prophecy II/ Dracula III: Legacy/ The House That Would Not Die/ Seedpeople/ The Greenskeeper/ Grim/ Evil Bong 3 & More
                    [UPC] => 096009092443
                    [ASIN] => B008R52L7K
                    [SalesRank] => 26999
                    [ImageURL] => http://ecx.images-amazon.com/images/I/617n-5nMLYL._SL200_.jpg
                    [ProductGroup] => DVD
                    [Publisher] => Echo Bridge Home Entertainment
                    [NumberOfDiscs] => 4
                )
        )
    [Pricing] => Array
        (
            [0] => Array
                (
                    [LowestPrice] => 3.03
                    [ShippingPrice] => 3.99
                    [TotalPrice] => 7.02
                )
            [1] => Array
                (
                    [LowestPrice] => 0.01
                    [ShippingPrice] => 3.99
                    [TotalPrice] => 4
                )
            [2] => Array
                (
                    [LowestPrice] => 22.19
                    [ShippingPrice] => 3.99
                    [TotalPrice] => 26.18
                )
            [3] => Array
                (
                    [LowestPrice] => 1.33
                    [ShippingPrice] => 3.99
                    [TotalPrice] => 5.32
                )
            [4] => Array
                (
                    [LowestPrice] => 0.74
                    [ShippingPrice] => 3.99
                    [TotalPrice] => 4.73
                )
        )
)

任何帮助都将是非常感激的。

谢谢,埃里克

for($index=0; $index<=4; $index++){
     $final_array[$index] = array_merge($product[$index],$pricing[$index]);
}

Try

foreach ($products as $key => $product){
   $products[$key] = array_merge($product, $prices[$key])
}

相关内容

  • 没有找到相关文章

最新更新