<?php$test = 'test1/test2/test3/test4';$arr = explode("/", $test); $t = "";$newArray = array();foreach($arr as $value) { $t .= "/".$value; $newArray[] = $t;} print_r($newArray);?>
Standard input is empty
Array ( [0] => /test1 [1] => /test1/test2 [2] => /test1/test2/test3 [3] => /test1/test2/test3/test4 )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!