小编Jen*_*fer的帖子

在PHP中回显多维数组

我有一个多维数组,我试图找出如何简单地"回显"数组的元素.数组的深度未知,因此可以深度嵌套.

在下面的数组的情况下,回显的正确顺序是:

This is a parent comment
This is a child comment
This is the 2nd child comment
This is another parent comment
Run Code Online (Sandbox Code Playgroud)

这是我正在谈论的数组:

Array
(
    [0] => Array
        (
            [comment_id] => 1
            [comment_content] => This is a parent comment
            [child] => Array
                (
                    [0] => Array
                        (
                            [comment_id] => 3
                            [comment_content] => This is a child comment
                            [child] => Array
                                (
                                    [0] => Array
                                        (
                                            [comment_id] => 4
                                            [comment_content] => This is the 2nd child comment
                                            [child] => Array …
Run Code Online (Sandbox Code Playgroud)

php arrays nested multidimensional-array

14
推荐指数
3
解决办法
7万
查看次数

标签 统计

arrays ×1

multidimensional-array ×1

nested ×1

php ×1