-1

I am using PHP Simple HTML DOM to try to count how many tags there are in an html document. The html document is structured as follows:

<div class="detailMS__incidentRow incidentRow--home even">
  <div class="time-box">48'</div>
  <div class="icon-box soccer-ball">
    <span class="icon soccer-ball">&nbsp;</span>
  </div>
  <span class="participant-name">
  <a href="#" onclick="window.open('/jugador/thiago-heleno/GfhW4pOT/'); return false;">Heleno T.</a>
  </span>
  <span class="assist note-name">
    (<a href="#" onclick="window.open('/jugador/veiga-raphael/0fYAKGcN/'); return false;">Veiga R.</a>)
  </span>
</div>

I am trying it in the following way:

$es = $html->find('div[class=detailMS__incidentRow incidentRow--home even], div[class=icon-box soccer-ball] div[class=icon-box soccer-ball], span[class=icon soccer-ball]');

But the result is a very large array ... And the browser is blocked.

How could I get it?

Phil
  • 157,677
  • 23
  • 242
  • 245
krosgore
  • 3
  • 2
  • 1
    Exactly which tags are you trying to count? FYI, SimpleHTMLDOM is a terrible library. See [How do you parse and process HTML/XML in PHP?](https://stackoverflow.com/a/3577662/283366) for better alternatives – Phil Oct 15 '18 at 06:02
  • Hi phil. I am trying to count the div tags that are in other div tags. But those that have a class in particular. Why simpleHTMLDOM is a terrible library? – krosgore Oct 15 '18 at 07:59
  • 1
    _“But the result is a very large array ... And the browser is blocked.”_ - well then don’t _output_ the content of the array, if that’s not what you need to begin with, but the _count_ of items it contains …? – misorude Oct 15 '18 at 08:06

1 Answers1

0

Solution:

$MarcoGolLocal = $html->find('div[class=detailMS] div[class=detailMS__incidentRow incidentRow--home even] div[class=icon-box soccer-ball] span[class=icon soccer-ball]');

$golesDeLocal = count($MarcoGolLocal) + count($MarcoGolLocal2);

krosgore
  • 3
  • 2