There is a list with categories of goods. In each li there is another list with subcategories. How can simple categories and subcategories be displayed using simple_html_dom? Thanks in advance

//подгружаем библиотеку require_once 'simple_html_dom.php'; //создаём новый объект $html = new simple_html_dom(); //загружаем в него данные $html = file_get_html('smeg-store.com.ua/'); if ($html->innertext!='' and count($html->find('nav.header__cats li ul '))) { foreach ($html->find('nav.header__cats li ul') as $a) { # code... echo $a->parent()->children(0)->innertext.'<br />'; echo $a->parent()->innertext.'<br />'; } } //освобождаем ресурсы $html->clear(); unset($html); 
  • where did you stop working? when setting the task? but what = simple_html_dom then? - splash58
  • It turns out separately to display categories and subcategories, but at the moment when there is a category without subcategories it is not possible to derive these categories - zh-mskl9
  • show the code, try to tell - splash58
  • <? php // load the library require_once 'simple_html_dom.php'; // create a new object $ html = new simple_html_dom (); // load data into it $ html = file_get_html (' smeg-store.com.ua/' ); if ($ html-> innertext! = '' and count ($ html-> find ('nav.header__cats li ul'))) {foreach ($ html-> find ('nav.header__cats li ul') as $ a ) {# code ... echo $ a-> parent () -> children (0) -> innertext. '<br />'; echo $ a-> parent () -> innertext. '<br />'; }} // release resources $ html-> clear (); unset ($ html); ?> - zh-mskl9
  • The first echo output separately categories that have subcategories, the second echo displays categories and subcategories, it is not possible to deduce categories that do not have subcategories - zh-mskl9

0