相关疑难解决方法(0)

PHP:如何确定循环的每个第N次迭代?

我希望通过XML发布每3个帖子后回显一个图像这里是我的代码:

<?php
// URL of the XML feed.
$feed = 'test.xml';
// How many items do we want to display?
//$display = 3;
// Check our XML file exists
if(!file_exists($feed)) {
  die('The XML file could not be found!');
}
// First, open the XML file.
$xml = simplexml_load_file($feed);
// Set the counter for counting how many items we've displayed.
$counter = 0;
// Start the loop to display each item.
foreach($xml->post as $post) {
  echo ' 
  <div style="float:left; width: 180px; …
Run Code Online (Sandbox Code Playgroud)

html php loops

52
推荐指数
4
解决办法
9万
查看次数

标签 统计

html ×1

loops ×1

php ×1