Awais Qarni
Awais Qarni

Reputation: 18006

access each value of associative array

hello how can i access or echo each element of this associative array

Array
(
    [0] => Array
        (
            [rule] => admin/user
            [title] => Users Management
            [target] => _parent
            [0] => Array
                (
                    [0] => Array
                        (
                            [rule] => admin/user/add
                            [title] => Add New User
                        )

                )

        )

    [1] => Array
        (
            [rule] => admin/category
            [title] => Category Mangement
            [target] => _parent
            [0] => Array
                (
                    [0] => Array
                        (
                            [rule] => admin/category/add
                            [title] => Add New Category
                        )

                )

        )

)

I want to know which loop will support this and how

Upvotes: 0

Views: 162

Answers (1)

Pascal MARTIN
Pascal MARTIN

Reputation: 400922

I suppose that using array_walk_recursive(), with a callback function that would do an echo, would be quite a good solution.

Upvotes: 4

Related Questions