Hello. A little I can not deal with recursion, namely how to build it. There are properties (for example, number of rooms, type of housing, etc.) and there are its values. I need to collect references of these values ​​depending on the nesting of their properties.

For example (number of rooms -> type of housing -> wall material):

  1. 1-komnatnie
  2. 1-komnatnie / vtorichka
  3. 1-komnatnie / vtorichka / kirpichnie

Perhaps I incorrectly created the table, so I can not catch up.

enter image description here

  1. n_category - the number of the category to which the property belongs (apartments)
  2. value_properties - property value
  3. link - property link
  4. name - name
  5. n_prop - id-properties (number of rooms, type of housing, etc.)
  6. priority - currently does not carry any information
  7. parent - parent n_prop

This method turned out to finish the lack of intelligence (((

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; } 

Thanks for any advice.

  • the last time you could not normally make a question? or your fantasy is constantly changing there. you come up with the final version, like yours and what should work, and then ask a question. and then people spend time, and you come up with new variations of questions - teran
  • Thanks for the constructive answer, they helped a lot. This resource serves to help in resolving issues. I am grateful to you for the answer last time, but I have a lot of questions and in 5 days ideas can change. I do not oblige you to help me and it’s your business to spend time with me or not! - Sarkis Allahverdian
  • We would have more information, what data will be at the entrance, how they are arranged and what requests to them will be. You seem to have decided to make a table in which the values ​​of all properties are located. Then for choosing 1-komnatnie / vtorichka / kirpichnie, etc. You can do this: as the first feature, select the list of matching id. Next, take the appropriate ID for the second sign, among the selected IDs for the first sign, etc. It is desirable that the first sign is the one that returns the minimum number of id. Sometimes this approach works. - Ivan Bolnikh

0