3v4l.org

run code in 300+ PHP versions simultaneously
<?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' ); $newFolders = array(); foreach ($folders as $file) { $parts = explode("/", $file); $newFolders[] = array( $parts[0] => $parts[1] ); } print_r($newFolders);

preferences:
41.15 ms | 402 KiB | 5 Q