将另一组结果添加到数组中
并不是百分百确定我在这里问的是什么。我想向我已经循环遍历的数组添加另一个级别。
$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
)
我说得有道理吗?谢谢你的帮助
斯图
Not really 100% sure what I am asking here. I want to add another level to an array which I am already looping through.
$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
}
}
So I currently have this:
Array
(
[0] => Array
(
[product_id] => 1
[sku] => TPF1
)
[1] => Array
(
[product_id] => 2
[sku] => TFL3
)
Am I making sense? Thank you for your help
Stu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在 $products 将包含每个项目的标题
now $products will containt each of the items title