Ma ktoś pomysł jak przelecieć przez tablice by była w tym formacie ? Każda kategoria ma rodzica wyżej i nieograniczoną liczę dzieci i dzieci tak samo.
Jedynie co potrzebuje by kluczem było id ostaniej kategorii. Prawie mi się udało zrobić, jednak pierwszy parent mi znika w niektórych kategoriach :/ dzieki za pomoc
Format jaki potrzebuje:
'1' => 'Pozdespoły' ), '1' => 'Pozdespoły' '2' => 'CPU' ), '1' => 'Pozdespoły' '2' => 'CPU', '3' => 'Intel' ), '1' => 'Pozdespoły' '2' => 'CPU', '3' => 'Intel', '5' => 'i5' ), '1' => 'Pozdespoły' '2' => 'CPU', '3' => 'Intel', '6' => 'i7' ), '1' => 'Pozdespoły' '2' => 'CPU', '4' => 'AMD' ) );
Format jaki mam:
'id' => 2, 'name' => 'CPU' 'parent_id' => 1 ), 'id' => 1, 'name' => 'Podzespoły', 'parent_id' => null ), 'id' => 3, 'name' => 'Intel', 'parent_id' => 2 ), 'id' => 2, 'name' => 'CPU', 'parent_id' => 1 ), 'id' => 5, 'name' => 'i5', 'parent_id' => 3 ), 'id' => 3, 'name' => 'Intel', 'parent_id' => 2 ), '0' => ...., '1' => ... ) ), 'id' => 6, 'name' => 'i7', 'parent_id' => 3 ), 'id' => 3, 'name' => 'Intel', 'parent_id' => 2 ), '0' => ...., '1' => .... ) ) ) ), 'id' => 4, 'name' => 'AMD', 'parent_id' => 2 ), 'id' => 2, 'name' => 'CPU', 'parent_id' => 1 ), '0' => ....., '1' => .... ) ) ) ), '1' ..... );