3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //directory to list, you choose; here we’ll just use the webroot $path = '.'; //warning: `is_dir` will need you to change to the parent directory of what you are testing //see <uk3.php.net/manual/en/function.is-dir.php#70005> for details chdir ($path); //get a directory listing $dir = array_diff (scandir ('.'), //folders / files to ignore array ('.DS_Store', 'Thumbs.db') ); //sort folders first, then by type, then alphabetically usort ($dir, create_function ('$a,$b', 'return is_dir ($a) ? (is_dir ($b) ? strnatcasecmp ($a, $b) : -1) : (is_dir ($b) ? 1 : ( strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION)) == 0 ? strnatcasecmp ($a, $b) : strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION)) )) ; ')); //echo to screen header ('content-type: text/plain'); print_r ($dir);
Output for 7.0.0 - 7.1.0
Warning: scandir(.): failed to open dir: Permission denied in /in/Cm8Fu on line 10 Warning: scandir(): (errno 13): Permission denied in /in/Cm8Fu on line 10 Warning: array_diff(): Argument #1 is not an array in /in/Cm8Fu on line 12 Warning: usort() expects parameter 1 to be array, null given in /in/Cm8Fu on line 26 Warning: Cannot modify header information - headers already sent by (output started at /in/Cm8Fu:10) in /in/Cm8Fu on line 29
Output for hhvm-3.10.0 - 3.12.0
Warning: Permission denied in /in/Cm8Fu on line 10 Warning: array_diff() expects parameter 1 to be an array or collection in /in/Cm8Fu on line 13 Warning: Invalid operand type was used: usort expects array(s) or collection(s) in /in/Cm8Fu on line 26
Output for 5.3.0 - 5.6.28
Warning: scandir(.): failed to open dir: Permission denied in /in/Cm8Fu on line 10 Warning: scandir(): (errno 13): Permission denied in /in/Cm8Fu on line 10 Warning: array_diff(): Argument #1 is not an array in /in/Cm8Fu on line 13 Warning: usort() expects parameter 1 to be array, null given in /in/Cm8Fu on line 26 Warning: Cannot modify header information - headers already sent by (output started at /in/Cm8Fu:10) in /in/Cm8Fu on line 29
Output for 5.2.3 - 5.2.17
Warning: scandir(.): failed to open dir: Permission denied in /in/Cm8Fu on line 10 Warning: scandir(): (errno 13): Permission denied in /in/Cm8Fu on line 10 Warning: array_diff(): Argument #1 is not an array in /in/Cm8Fu on line 13 Warning: usort(): The argument should be an array in /in/Cm8Fu on line 26 Warning: Cannot modify header information - headers already sent by (output started at /in/Cm8Fu:10) in /in/Cm8Fu on line 29
Output for 5.0.0 - 5.2.2
Warning: scandir(.): failed to open dir: Permission denied in /in/Cm8Fu on line 10 Warning: scandir(): (errno 13): Permission denied in /in/Cm8Fu on line 10 Warning: array_diff(): Argument #1 is not an array in /in/Cm8Fu on line 13 Warning: usort(): The argument should be an array in /in/Cm8Fu on line 26
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: scandir() in /in/Cm8Fu on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: scandir() in /in/Cm8Fu on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: scandir() in /in/Cm8Fu on line 10