将另一组结果添加到数组中


Add another set of results to an array

不是100%确定我在这里问什么。我想在一个已经循环过的数组中添加另一个级别。

$product_query = mysql_query("SELECT * FROM table");
while ($row = mysql_fetch_assoc($product_query)) {$products[] = $row;}
 foreach($products as $product){
  //external array request is here which then generates this:
  foreach ($Items->Item as $Items){
   echo $Items->title; // I want to add these value**s** to the existing $products array
  }
 }

所以我现在有这个:

Array
(
    [0] => Array
        (
            [product_id] => 1
            [sku] => TPF1
        )
    [1] => Array
        (
            [product_id] => 2
            [sku] => TFL3
        )

我说的有意义吗?谢谢你的帮助

Stu

$product_query = mysql_query("SELECT * FROM table"); 
while ($row = mysql_fetch_assoc($product_query)) {$products[] = $row;} 
 foreach($products as &$product) { //notice the ambersand
     foreach ($Items->Item as $Item){ 
        $product['title'] =  $Item->title; 
  } 
}

现在$products将包含每个项目标题