I am trying to find a way to create an array of directories. But as we all know directories can have many subDirs and those subDirs can have more subDir and so on and on. The directories length are unknown as it can change.
Say I have a directory as www/webs/apps/pics
and another www/webs/test
.
The idea would be to have an array such as: (yes the below is json, i just converted it in my php demonstration because i find it easier to read)
{
"www": {
"webs": {
"apps": {
"pics": "Im Here"
}
},
"test": "im Here too"
}
}
There is no relation from the above output to the below code. The below code is here just to give an idea what I need.
$exploedDir = explode("/", $unsortedDir);
foreach ($exploedDir as $dir){
$this->allDirectiroesFound[$dir] = $dir;
}
How can I make $this->allDirectiroesFound
has as many dimensions as it is needed without knowing the length of the directory, I cant hard code $this->allDirectiroesFound[][][][][][]
it as next time around the array length might be [][][]
.