我得到了下面的目录数组。
我将在这个数组中进行文件搜索。例如path.php, survey.php…如果找到了文件,该如何构造路径
为path.php我希望函数返回'/survey/config/path.php'
Array
(
[survey] => Array
(
[config] => Array
(
[0] => path.php
[1] => routes.php
)
[controllers] => Array
(
[0] => admin.php
[1] => giris.php
)
[models] => Array
(
[0] => giris.php
)
[views] => Array
(
[0] => admin_form.php
[1] => widget.php
[2] => yeni_form.php
)
[widgets] => Array
(
[0] => survey.php
)
)
)
function find_file_path($dir_structure, $filename) {
foreach($dir_structure as $dir => $subpath) {
if(is_array($subpath)) {
$sub_found = find_file_path($subpath, $filename);
if($sub_found) {
return "/" . $dir . $sub_found;
}
} else {
if($subpath === $filename) {
return "/$filename";
}
}
}
return FALSE;
}