Задать вопрос
@sunnyrio

Как пройтись по многомерному массиву с n-вложенностями?

Есть многомерный массив категорий как пройтись по нему чтобы найти все последние элементы?
Array
(
    [id] => 685
    [title] => Baby
    [parent] => 0
    [alias] => komplektuyuschie-k-apple
    [childs] => Array
        (
            [691] => Array
                (
                    [id] => 691
                    [title] => Baby boy 0-24 months
                    [parent] => 685
                    [alias] => zapchasti-ipad
                    [childs] => Array
                        (
                            [695] => Array
                                (
                                    [id] => 695
                                    [title] => iPad
                                    [parent] => 691
                                    [alias] => ipad
                                )

                            [696] => Array
                                (
                                    [id] => 696
                                    [title] => iPad 2
                                    [parent] => 691
                                    [alias] => ipad-2
                                )

                            [697] => Array
                                (
                                    [id] => 697
                                    [title] => iPad NEW (iPad 3)
                                    [parent] => 691
                                    [alias] => ipad-new-ipad-3
                                )

                            [698] => Array
                                (
                                    [id] => 698
                                    [title] => iPad 4
                                    [parent] => 691
                                    [alias] => ipad-4
                                )

                            [699] => Array
                                (
                                    [id] => 699
                                    [title] => iPad mini
                                    [parent] => 691
                                    [alias] => ipad-mini
                                )

                        )

                )

            [692] => Array
                (
                    [id] => 692
                    [title] => Baby girl 0-24 months
                    [parent] => 685
                    [alias] => zapchasti-iphone
                    [childs] => Array
                        (
                            [700] => Array
                                (
                                    [id] => 700
                                    [title] => iPhone
                                    [parent] => 692
                                    [alias] => iphone
                                )

                            [701] => Array
                                (
                                    [id] => 701
                                    [title] => iPhone 3G/3GS
                                    [parent] => 692
                                    [alias] => iphone-3g-3gs
                                )

                            [702] => Array
                                (
                                    [id] => 702
                                    [title] => iPhone 4
                                    [parent] => 692
                                    [alias] => iphone-4
                                )

                            [703] => Array
                                (
                                    [id] => 703
                                    [title] => iPhone 4S
                                    [parent] => 692
                                    [alias] => iphone-4s
                                )

                            [704] => Array
                                (
                                    [id] => 704
                                    [title] => iPhone 5
                                    [parent] => 692
                                    [alias] => iphone-5
                                )

                        )

                )

            [693] => Array
                (
                    [id] => 693
                    [title] => Toddler boy 2t-5t
                    [parent] => 685
                    [alias] => zapchasti-ipod
                )

            [694] => Array
                (
                    [id] => 694
                    [title] => Toddler girl 2t-5t
                    [parent] => 685
                    [alias] => zapchasti-mac
                )

            [705] => Array
                (
                    [id] => 705
                    [title] => Baby furniture
                    [parent] => 685
                    [alias] => mikroshemy-apple
                )

            [836] => Array
                (
                    [id] => 836
                    [title] => Fashion
                    [parent] => 685
                    [alias] => zaschitnye-plenki-na-apple
                    [childs] => Array
                        (
                            [840] => Array
                                (
                                    [id] => 840
                                    [title] => iPad
                                    [parent] => 836
                                    [alias] => ipad-840
                                )

                            [841] => Array
                                (
                                    [id] => 841
                                    [title] => iPhone
                                    [parent] => 836
                                    [alias] => iphone-841
                                )

                            [842] => Array
                                (
                                    [id] => 842
                                    [title] => iPod
                                    [parent] => 836
                                    [alias] => ipod
                                )

                            [843] => Array
                                (
                                    [id] => 843
                                    [title] => Mac
                                    [parent] => 836
                                    [alias] => mac
                                )

                        )

                )

            [853] => Array
                (
                    [id] => 853
                    [title] => Cakes
                    [parent] => 685
                    [alias] => oborudovanie-dlya-remonta-apple
                )
  • Вопрос задан
  • 128 просмотров
Подписаться 1 Простой Комментировать
Решения вопроса 1
@ksnk
Рекурсия. Каждое "погружение" вглубь дерева категорий - нужно параметр функции увеличивать на единичку
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
18 дек. 2024, в 13:22
30000 руб./за проект
18 дек. 2024, в 12:37
10000 руб./за проект
18 дек. 2024, в 12:22
5000 руб./за проект