在写入当前dir路径和放置sub时循环出一个子树菜单

时间:2015-11-21 14:12:02

标签: php file menu directory

我想循环一个子树菜单,但我无法弄清楚如何做到这一点。

我需要覆盖当前目录路径并放置子。

这是我的预期输出:

../ uploads / username / folder0 / | file1,file2,file3,file4 |

../ uploads / username / | file1,file2,file3,file4,file5,file6,file7 | folder1 / | file1,file2,file3,file4 | folder2 / folder3 / | file1,file2 | folder4 / | file1,file2,file3,file4 |

这是我的代码:

<?php

$list_array = Array(
    // Presumed to have been coming from a SQL SELECT, populated for demo.
    Array(
        'path' => '../uploads/username/folder0/',
        'subs' => 'file1, file2, file3, file4'
    ),
    Array(
        'path' => '../uploads/username/folder1/folder2/folder3/',
        'subs' => 'file1, file2'
    ),
    Array(
        'path' => '../uploads/username/folder1/folder2/folder3/folder4/',
        'subs' => 'file1, file2, file3'
    ),
    Array(
        'path' => '../uploads/username/',
        'subs' => 'file1, file2, file3, file4, file5, file6 file7'
    ),
    Array(
        'path' => '../uploads/username/folder1/',
        'subs' => 'file1, file2, file3, file4'
    )
);

$x = 1;

foreach ($list_array as $list_arrays) {
    //do something with loop        
}

?>

0 个答案:

没有答案