0

I'm using Symfony DomCrawler to parse my HTML. I'm reading articles on my website like this:

$domCrawler->filter('.post')->each(function (DomCrawler $post) {
    // ...
});

How can I walk through them backwards? I'd like to start from the post that is at the very bottom of the page and then go up.

Robo Robok
  • 21,132
  • 17
  • 68
  • 126

1 Answers1

0

Your can use count and eq functions. Do something like this.

for ($i = $nodes->count() - 1; $i >= 0; $i--) {
     $node = $nodes->eq($i);
}
Gras Double
  • 15,901
  • 8
  • 56
  • 54
Yoann
  • 4,937
  • 1
  • 29
  • 47