&1", $output); exec("git ls-files -z ../icons", $raw_img_list); $raw_img_list = explode("\x00", $raw_img_list[0]); $img_list = []; foreach ($raw_img_list as $path) { $pos = strpos($path, '../icons/'); if($pos === false){ continue; } $path = substr($path, $pos + 9); $dpath = dirname($path); $filename = basename($path); if(!\key_exists($dpath, $img_list)){ $img_list[$dpath] = []; } $img_list[$dpath][] = $filename; } file_put_contents('list.json', json_encode($img_list, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));