处理订单 xml 以直接运送给供应商,他们希望将产品添加到一定数量的数量,因此不xmlwriter 的部分是在按下订单按钮并且管理员收到管理员警报时但我真的看不到或找不到可以做到这一点的代码foreach ($order_products as $order_product) {$writer->startElement("products");$writer->writeElement('art', $order_product['model']);$writer->writeElement('quantity',$order_product['quantity']);// what i thought of was $order_product['quantity'] * $writer->writeElement('art', $order_product['model']); ;// something like that really dont know where to start with this one$writer->endElement();}what the suplier wants is if quantity is 3<product>1234</product><product>1234</product><product>1234</product>
1 回答
扬帆大鱼
TA贡献1799条经验 获得超9个赞
如果需要<art>多次添加基于quantity,只需创建一个 for 循环:
for ( $i = 0; $i < $order_product['quantity']; $i++ )
{
$writer->writeElement( 'art', $order_product['model'] );
}
https://www.php.net/manual/en/control-structures.for.php
- 1 回答
- 0 关注
- 152 浏览
添加回答
举报
0/150
提交
取消