Здравствуйте!
Подскажите как правильно сделать рекурсивное заполнение массива в функции.. запутался..
function rotator_scan_localStorage($directory) {
$songs = []; $valid_ext = array("mp3", "wav", "m3u");
if($local_storage = opendir($directory)){
while(false !== ($file = readdir($local_storage))) {
if($file != "." && $file != ".."){
if(is_file($directory.'/'.$file) AND in_array(rotator_getExtension($file),$valid_ext) ){
$songs['media_'.$file]['filename'] = str_replace('.'.rotator_getExtension($file), "", $file);
$songs['media_'.$file]['tags'] = rotator_get_tags($directory.'/'.$file);
$songs['media_'.$file]['song_path'] = $directory.'/'.$file;
$songs['media_'.$file]['song_url'] = LOCAL_MEDIALIB_URL.'/'.$file;
if($directory !== LOCAL_MEDIALIB_PATH){ $songs['media_'.$file]['intended_cat'] = str_replace(LOCAL_MEDIALIB_PATH.'/', "", $directory); }
}
elseif(is_dir($directory.'/'.$file)){
rotator_scan_localStorage($directory.'/'.$file);
}
}
}
}
return $songs;
}