dongzituo5530 2016-03-04 18:04
浏览 69

PHP简单的HTML DOM解析器:得到“致命错误:嵌套级别太深 - 递归依赖?

I'm trying to parse a cinema webpage and get the movie schedule for the upcoming days. The following code shows what I've done till now:

foreach ($html -> find('div[id*=tabs]') as $days) {
    foreach($days -> find('div[!class]') as $good_days) {
        echo $good_days
        foreach($good_days -> find('a') as $title) {
            if (empty($movie_names)) {          
                $movie_names[] = $title;
            }
            if (!in_array($title, $movie_names)) {
                $movie_names[] = $title;
            }
        }
    }
}

If I keep the code at echo $good_days, everything goes smoothly and I get a table-like of the scheduled movies, as shown in the picture: echo $good_days If I try to get only the names of the movies, I get the first day titles, and as it starts parsing the second I get

Fatal error: Nesting level too deep - recursive dependency?

on the

if (in_array($title, $movie_names)) {

line. I don't get what is wrong with the code and I can't understand the error at all. Any suggestion?

  • 写回答

1条回答 默认 最新

  • dongxiaofa6359 2017-10-02 15:38
    关注

    Solved. I just had to set $title->plaintext

    评论

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像