0
我使用php simplexml和foreach循环一个xml文件。 代码就像php simplexml foreach while while循环
$xml = simplexml_load_file(myfile.xml);
foreach($xml->contents as $list){
$name= $list->name;
$price=$list->price;
$prob=$list->Price;
echo $name, $price, $prob;
}
如果我有100个项目,我怎么可以插入每5项类?
输出像
<div id="showup">
$name, $price, $prob (1)
$name, $price, $prob (2)
$name, $price, $prob (3)
$name, $price, $prob (4)
$name, $price, $prob (5)
</div>
<div id="showup">
$name, $price, $prob (6)
$name, $price, $prob (7)
$name, $price, $prob (8)
$name, $price, $prob (9)
$name, $price, $prob (10)
</div>
...............
我必须使用时间,而不是的foreach? foreach的优点是,我不需要计算xml文件中有多少项。或者我可以同时使用
希望有人能够帮助,谢谢:-)
谢谢你,这就是我要寻找:-) – olo
欢迎您.. :) –