I would like to concatenate each element of array to next one. I want the output array to be:

```
Array
(
[0] => test
[1] => test/test2
[2] => test/test2/test3
[3] => test/test2/test3/test4
)

```

I tried the following way which concatenates each string to itself:

```
$url = preg_split("/[\s\/]+/", "test/test2/test3/test4");
foreach ($url as $dir) {
   $dir .= $dir;
} 

```

Any help appreciated.