【发布时间】:2017-03-02 11:46:19
【问题描述】:
我正在尝试为另一个市场设置 CSV 提要。 问题是只有一组值存储到数组中。
$data = array();
while ($loop->have_posts()) : $loop->the_post();
$product = get_product($loop->post);
$title = $product->get_title();
$link = get_permalink();
$description = strip_tags($post->post_content);
$details = $post->the_excerpt;
$categories = get_the_terms($post->ID, 'product_cat');
$sku = $product->get_sku();
$price = $product->price;
$imageinfo = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID));
$imageurl = $imageinfo[0];
$image = preg_replace($suchmuster, '', $imageurl);
foreach ($categories as $c) {
$category = $c->name;
}
$data += [
"ean" => $sku,
"condition" => "100",
"listing_price" => $price,
"minimum_price" => $price,
"amount" => 9,
"delivery_time" => "b",
"location" => "DE"
];
endwhile;
wp_reset_query();
echo '<pre>';
print_r($data);
echo '</pre>';
我的数组现在看起来像这样:
Array
(
[ean] => SportsBag16
[condition] => 100
[listing_price] => 39
[minimum_price] => 39
[amount] => 9
[delivery_time] => b
[location] => DE
)
但是应该有更多的条目(22)。
我做错了什么?感谢您的帮助。
【问题讨论】:
标签: php arrays loops multidimensional-array