FriendsOfPHP / Goutte

Goutte, a simple PHP Web Scraper
MIT License
9.26k stars 1.01k forks source link

How can i break each #403

Open shinedira opened 4 years ago

shinedira commented 4 years ago

i want to break foreach on each chain on filter

Nemesis19 commented 4 years ago

instead of doing that you can use a foreach loop where you can use a break.

imagine to have something like $nodes = $crawler->filter('.someclass'); that returns an array of multiple .someclass elements.

Then you can do: foreach ($nodes as $node) { $dom = new Crawler($node); // your other code }

then everything else...and because it's a foreach loop you can break it