3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function dirToArray($dir) { $result = array(); $cdir = scandir($dir); foreach ($cdir as $key => $value) { if (!in_array($value,array(".",".."))) { if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) { $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value); } else { $result[] = $value; } } } return $result; } print_r(dirToArray('/'));
Output for 5.0.0 - 7.1.7
Warning: scandir(/): failed to open dir: Permission denied in /in/V9R4Q on line 6 Warning: scandir(): (errno 13): Permission denied in /in/V9R4Q on line 6 Warning: Invalid argument supplied for foreach() in /in/V9R4Q on line 7 Array ( )
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: scandir() in /in/V9R4Q on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: scandir() in /in/V9R4Q on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: scandir() in /in/V9R4Q on line 6