Deep recursive array of directory structure in PHP

后端 未结 5 2272
有刺的猬
有刺的猬 2020-11-27 18:22

I\'m trying to put some folders on my hard-drive into an array.

For instance, vacation pictures. Let\'s say we have this structure:

  • Set 1
    • Ite
5条回答
  •  再見小時候
    2020-11-27 19:22

    I've had success with the PEAR File_Find package, specifically the mapTreeMultiple() method. Your code would become something like:

    require_once 'File/Find.php';
    $fileList = File_Find::mapTreeMultiple($dirPath);
    

    This should return an array similar to what you're asking for.

提交回复
热议问题