3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $folders = array( 'test/something.txt', 'test/hello.txt', 'test/another-folder/myfile.txt', 'test/another-folder/kamil.txt', 'test/another-folder/john/hi.txt' ); foreach ($folders as $file) { $parts = explode("/", $file); $newFolders = array( $parts[0] => $parts[1] ); } print_r($newFolders);
Output for 4.3.0 - 7.1.7
Array ( [test] => another-folder )