PHP simple HTML DOM Parser: getting "Fatal error: Nesting level too deep - recursive dependency?

时间:2016-03-04 18:04:24

标签: php html parsing

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 个答案:

答案 0 :(得分:1)

解决。 我只需要设置$title->plaintext