dtml3340 2012-03-06 08:48
浏览 26
已采纳

Foreach循环在一次迭代后死亡

I've been experimenting with ScraperWiki and yesterday, I could get a list of all lis in the DOM. Now, however, I only run through one iteration.

This is my code

$html = 'www.blah...'
$dom = new simple_html_dom();
$dom->load($html);
print_r('Starting parse');
$events = $dom->find("ul.listing li");
print_r('Found '.count($events).' events'); // shows there are 26 nodes
foreach($events as $data){
 // perform some processing then print to the console

I'm not really a PHP guy so I may be missing something obvious. The full source is at https://scraperwiki.com/scrapers/days_of_the_year/

  • 写回答

2条回答 默认 最新

  • dsilhx5830 2012-03-06 09:23
    关注

    How very clumsy of me. I was missing the fact that the output was truncated after one line in the console. I added a linebreak and now get the expected output.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办