【发布时间】:2014-03-09 22:42:32
【问题描述】:
如何从目录中提取文件名列表并将它们存储到 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.plist 的 xml 文件中获取捆绑包 ID 并将其存储到数组中的某种方式。类似于 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;
}
}
【问题讨论】:
-
请一次一个问题,除非它们非常相关。在这种情况下,解析 XML 和获取文件列表是不相关的。
-
对不起!有很多事情要弄清楚。不要试图压倒任何人。
标签: php xml bash plist info.plist