G
G
Good Samaritan2018-02-02 11:01:47
PHP
Good Samaritan, 2018-02-02 11:01:47

How can I use the SIMPLE HTML DOM parser to display all blocks with the same classes in sequence?

$html = file_get_html('http://uriya/ru/');

    foreach ($html->find(".programs-page-wrapper") as $elsements) {
      $categories = $elsements;
    }
    echo $categories;

The parser displays only the last element with the programs-page-wrapper class, and there are several of them on the page. How to withdraw everything?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-02-02
@djamali

foreach ($html->find(".programs-page-wrapper") as $elements) {
  $categories = $elements;
  echo $categories;
}

so or
foreach ($html->find(".programs-page-wrapper") as $elements) {
  $categories[] = $elements;
}
echo implode('', $categories);

or
foreach ($html->find(".programs-page-wrapper") as $elements) {
  $categories .= $elements;
}
echo $categories;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question