2013-07-18 109 views
2

我有像這樣PHP從另一個陣列抓一個陣列

Array (
    [0] => Array (
     [64579] => Array (
      [title] => title 
      [description] => blah, blah, blah 
      [image] => Array (
       [original] => Array ([src] => image1.jpg) 
       [reference] => Array ([src] => image1_big.jpg) 
       [thumb] => Array ([src] => image1_thumb.jpg) 
      ) 

數組我試圖抓住的是參考圖像的SRC ......我曾嘗試以下

foreach($images as $row => $value){ 
       $gallery[] = $value['image']; 
} 

但它返回像這樣

Array ([0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => [20] => [21] => [22] => [23] => [24] => [25] => [26] => [27] => [28] => [29] => [30] => [31] => [32] => [33] => [34] => [35] => [36] => [37] => [38] => [39] => [40] => [41] => [42] => [43] => [44] => [45] => [46] => [47] => [48] =>) 

我該怎麼做才能將參考圖像src添加到我的新庫數組?

回答

2

你有什麼是三維陣列...你需要在另一個循環來包裝這個..

foreach($images as $imageGroupList) 
    foreach($imageGroupList as $row => $value){ 
      $gallery[] = $value['image']; 
    } 
} 
如果你的頂層陣列只有永遠有你可以重複它的單個元素的

foreach($images[0] as $row => $value){ 
     $gallery[] = $value['image']; 
}