我正在尝试在 do-while 循环内进行 simplexml 计数,是的,它很简单,但计数不正确,因为它在 2 个循环内。有没有更简单的计数方法?
$query_fl = "SELECT * FROM table";
$fl = mysql_query($query_fl, $rf) or die(mysql_error());
$row_fl = mysql_fetch_assoc($fl);
do {
$xml = $row_fl['fu'];
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$rss = simplexml_load_file($xml);
$items = $rss->channel->item;
foreach($items as $item){
echo $rss->channel->title;
echo $feed_count."<BR>";
$feed_count++;
}
$feed_count=1;
} while ($row_fl = mysql_fetch_assoc($fl));
-------------输出是这样的
Feed 1 - Count-1
Feed 1 - Count-2
Feed 1 - Count-3
Feed 1 - Count-4
Feed 1 - Count-5
Feed 2 - Count- 1
Feed 2 - Count- 2
Feed 2 - Count- 3
...
..
---------------我希望输出为
Feed 1 - Count-5
Feed 2 - Count-3