Answer the question
In order to leave comments, you need to log in
How to do recursion?
Hello. I can’t figure out a bit with recursion, namely how to build it. There are properties (for example, number of rooms, type of housing, etc.) and there are their values. I need to collect references of these values depending on the nesting of their properties.
For example (number of rooms -> housing type -> wall material):
1-roomatnie
1-room/vtorichka
1-room/vtorichka/kirpichnie
Maybe I created the table incorrectly, so I can't catch up.
function get_data_dynamic_link($data,$parent=0){
$tree = array();
foreach ($data as $id=> $value) {
$tree[] = $value['link'];
//$tree[] = $this->get_data_dynamic_link($data,$value['parent']);
}
return $tree;
}
Answer the question
In order to leave comments, you need to log in
Recursion is not needed to collect the url, just glue the array via implode with the separator / and get /cat/cat2/cat3 as the output, the order of the lines can be determined even when selecting through sort by parenr asc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question