嗨我想循环浏览一些项目,输出如下:
"&product_url[1]=http://www.result1.com&product_url[2]=http://www.result2.com&product_url[3]=http://www.result3.com"
所以循环并在每个项目前面加上一个增加的数字,从1开始。
有什么想法吗?
// get order items details
$order_items = $order->get_items();
// loop through items in order
foreach ( $order_items as $order_item ) {
$product_link = get_permalink($product_id)
echo $product_link;
}
答案 0 :(得分:0)
你可以这样做:
// get order items details
$counter = 1;
$url = "";
$order_items = $order->get_items();
// loop through items in order
foreach ( $order_items as $order_item ) {
$product_link = get_permalink($product_id)
$url .= "&product_url[$counter]=" . $product_link;
$counter ++;
}
echo $url; // <-- here you will have the url.