M
M
Maxim Lykov2016-08-12 10:31:01
PHP
Maxim Lykov, 2016-08-12 10:31:01

How to parse product catalog sections?

You need to parse sections into an array of this format:
id | caption | link | parent_id | last
id - Numbering of sections
caption - Product name
link - link
parrent_id - Id of the parent (for example, the section "Jackets" can be included in the section "Outerwear" with id 5, then parrent_id = 5)
last - whether the section is the last, deepest ( there are no further sections, only goods)
The problem is this:
If the depth of the sections was exact, for example 3, then there should be 3 cycles

foreach() {
    foreach() {
        foreach() {
        }
   }
}

But what if the depth of one section can be one, and the other another?
Website: detiopt96.com
Language: PHP

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hetzerok, 2016-08-12
@hetzerok

Recursion or loop with !$last condition or closure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question