There is an array
$shop_categories = [ [ 'title' => 'Компьютеры', 'children' => [ [ 'title' => 'Ноутбуки', ], [ 'title' => 'Моноблоки', ], [ 'title' => 'Системные блоки', 'children' => [ [ 'title' => 'Tower', ], [ 'title' => 'Mini Tower', ] ] ] ] ], [ 'title' => 'Бытовая техника', 'children' => [ [ 'title' => 'Пылесосы', ], [ 'title' => 'Холодильники', ] ] ] ]; As with the help of a single function print_cats ($ shop_categories), the easiest way to display a tree is as follows:
Computers:
Laptops
Monoblocks
System blocks
- Tower
- Mini Tower
Appliances:
Vacuum cleaners
Refrigerators
foreach ($shop_categories as $category) { echo $category['title']; if ($category['children']) { print_cats($category['children']); } }foreach ($shop_categories as $category) { echo $category['title']; if ($category['children']) { print_cats($category['children']); } }- Alexey Shimanskyulandlior to style it yourself .... or is it difficult do it yourself? ........ and then replace if withif (isset($category['children']))- Alexey Shimansky