как переделать функцию вывода JSON
function getDirTree($path)
{
$result = [];
$files = scandir($path);
foreach ($files as $file) {
if(! in_array($file, ['.','..','.idea','~components','~Arhive', '_plug'])) {
if(is_dir($path . DIRECTORY_SEPARATOR . $file)) {
$result[$file] = getDirTree($path . DIRECTORY_SEPARATOR . $file);
} else {
// $result[] = $file;
}
}
}
return $result;
}
$data = getDirTree('__Offers');
echo json_encode($data);
эта функция выдает объект с параметрами
{
"dir1":{...},
"dir2":{...},
"dir3":{...}
}
как ее переделать что бы получать массив с объектами ?
[
{"dir1":{...}},
{"dir2":{...}},
{"dir3":{...}}
]