动态array_merge

I have an array which looks like this:

array(2) { 
    [0]=> array(2) { 
        [0]=> string(52) "./app/pictures/uploads/Audi/A1/name1.jpg" 
        [1]=> string(52) "./app/pictures/uploads/Audi/A1/name2.jpg" 
    } 
    [1]=> array(1) { 
        [0]=> string(52) "./app/pictures/uploads/Audi/A3/name3.jpg" 
    } 
} 

The array above can have more than the two keys(0,1). A little bit more information, would be that I look through a folder. If there are subfolders, it puts every subfolder in an array and the content/files of those subfolders in that arrays.

So for my result I need something like this:

array(3) { 
    [0]=> string(52) "./app/pictures/uploads/Audi/A1/name1.jpg" 
    [1]=> string(52) "./app/pictures/uploads/Audi/A1/name2.jpg" 
    [2]=> string(52) "./app/pictures/uploads/Audi/A3/name3.jpg" 
}

I realized that with an array_merge:

$array = array_merge($tmparray[0],$tmparray[1]);

Now you can see that the keys in here are fixed. But they should be dynamic. How can I realize that? Maybe a loop but I didn't get the clue, that the $array variable isn't overridden every time in that loop...

Maybe it's too late to have a clear mind for that but I need a solution very soon.

You just need to loop over the parent array and then merge the children into an auxiliary variable:

$result = array();
foreach ($directories as $array) {
    $result = array_merge($result, $array);
}

Assume $directories is your multi-level array and $merged is what you want. Then:

$merged = array();
foreach($directories as $dir) {
   foreach($dir as $file) {
       $merged[] = $file;
   }
}