So I have a file that has strings of file paths that look like this..
./CatDV/S1/SFX/steam/6004_90_04 LargeHeadlightSm.wav
./CatDV/S1/SFX/steam/AirHissPressureRe HIT032001.wav
./CatDV/S1/SFX/steam/Impact_Metal_Bullet_Hit(1).wav
./CatDV/S1/SFX/steam/Impact_Metal_Bullet_Hit.wav
./CatDV/S1/SFX/steam/6004_94_02 LargeHeavyGlassS.wav
./CatDV/S1/SFX/steam/Impact_Glass_Smash.wav
./CatDV/S1/SFX/steam/AirReleaseHeavyAi HIT030701.wav
./CatDV/S1/SFX/steam/SDR02_15SCIF RhythmicRever.wav
./CatDV/S1/SFX/steam/VAL02_08CRSH GlassBreaking.wav
./CatDV/S1/SFX/steam/AirReleaseLargeAi HIT030601.wav
./CatDV/S1/SFX/steam/SDR02_14SCIF Rhythmic3Beat.wav
./CatDV/S1/SFX/steam/6004_94_01 LargeGlassSmash.wav
I want to split all of these to an ul li list.so
> CatDV
> S1
> SFX
> steam
> filename.extension
And so forth...
This is the array that i'm working with. And i got this to output with the function below.
array(1) {
[""]=>
array(1) {
["CatDV"]=>
array(1) {
["S1"]=>
array(1) {
["SFX"]=>
array(1) {
["steam"]=>
array(12) {
["6004_90_04 LargeHeadlightSm.wav"]=>
string(52) "./CatDV/S1/SFX/steam/6004_90_04 LargeHeadlightSm.wav"
["AirHissPressureRe HIT032001.wav"]=>
string(52) "./CatDV/S1/SFX/steam/AirHissPressureRe HIT032001.wav"
["Impact_Metal_Bullet_Hit(1).wav"]=>
string(51) "./CatDV/S1/SFX/steam/Impact_Metal_Bullet_Hit(1).wav"
["Impact_Metal_Bullet_Hit.wav"]=>
string(48) "./CatDV/S1/SFX/steam/Impact_Metal_Bullet_Hit.wav"
["6004_94_02 LargeHeavyGlassS.wav"]=>
string(52) "./CatDV/S1/SFX/steam/6004_94_02 LargeHeavyGlassS.wav"
["Impact_Glass_Smash.wav"]=>
string(43) "./CatDV/S1/SFX/steam/Impact_Glass_Smash.wav"
["AirReleaseHeavyAi HIT030701.wav"]=>
string(52) "./CatDV/S1/SFX/steam/AirReleaseHeavyAi HIT030701.wav"
["SDR02_15SCIF RhythmicRever.wav"]=>
string(51) "./CatDV/S1/SFX/steam/SDR02_15SCIF RhythmicRever.wav"
["VAL02_08CRSH GlassBreaking.wav"]=>
string(51) "./CatDV/S1/SFX/steam/VAL02_08CRSH GlassBreaking.wav"
["AirReleaseLargeAi HIT030601.wav"]=>
string(52) "./CatDV/S1/SFX/steam/AirReleaseLargeAi HIT030601.wav"
["SDR02_14SCIF Rhythmic3Beat.wav"]=>
string(51) "./CatDV/S1/SFX/steam/SDR02_14SCIF Rhythmic3Beat.wav"
["6004_94_01 LargeGlassSmash.wav"]=>
string(51) "./CatDV/S1/SFX/steam/6004_94_01 LargeGlassSmash.wav"
}
}
}
}
}
}
Now what I'm getting stuck in converting this into an ul li list that i can output into my html and style it.
function arch_list($output) {
// //Conditional for Archives Page
$data = file(get_template_directory_uri() . '/js/angular/data/list_test.txt', FILE_IGNORE_NEW_LINES);
$path = array('data' => $data);
$output = array();
foreach ($path['data'] as $d) {
$out = preg_split('/(\.)*\//', $d);
$outArr = $d;
for ($i = count($out) - 1; $i >= 0; $i--) {
$outArr = array($out[$i] => $outArr);
}
// return $outArr;
$output = array_merge_recursive($output, $outArr);
}
return $output;
}
Any help is appreciated! Thanks.
` and inside the `foreach()` wrap each value with ``. You could also write it as a recursive function that will do it n-levels deep in case your structure changes / is dynamic. – Sean May 20 '14 at 19:33