3v4l.org

run code in 150+ 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' ); $newFolders = array(); foreach ($folders as $file) { $parts = explode("/", $file); if (array_key_exists($parts[0], $parts)) { $newFolders = array( $parts[0][] => $parts[1] ); } else { $newFolders = array( $parts[0] => $parts[1] ); } } print_r($newFolders);
Output for 5.3.0 - 5.4.27
Fatal error: Cannot use [] for reading in /in/8IL5a on line 17
Process exited with code 255.