PHP函数将目录中的文件名列表拉到PHP数组中


php function pull list of file names in directory into a php array

如何从目录中提取文件名列表并将其存储到php中的数组中?

如何从xml文档中获取值?

如何将目录中文件的路径/名称存储到数组中?

又名:

$proj_dir = "~/directory/path/to/project_files;"; // same as output from {query}
$data_dir = "~/directory/path/to/data_files;";
$query = "{query}"; // returns path to project being accessed. current output of $proj_dir

从名为info的xml文件中获取bundle id的一种方法。Plist并将其存储到数组中。类似于json_decode()

$bundle_id_from_proj = function_to_pull_bundleid_out_of_the_file("bundle_id", '"{query}" . "/info.plist"');
$directories = array();
$cmd1 = # some way to get names of files in data/ directory via bash script
exec("$cmd");
$directories = # some way to pull values out of that array and store in php array
foreach ($directories as $directory) {
     // if title of a directory in data directories = bundleID of project
     if ( $directories['title'] === $bundle_id_from_proj )
     {
          $cmd2 = 'open -a Finder "$directory"';
          exec("$cmd2");
     }
     else
     {
          $cmd3 = 'Sorry! Can''t find it';
          echo $cmd3;
     }
}

使用glob()获取目录内的文件/目录列表