From 8d82cde120e531b271747895dba81b0d0b4c6d6e Mon Sep 17 00:00:00 2001 From: Danyel Bayraktar Date: Tue, 14 Jul 2015 13:31:51 +0200 Subject: [PATCH] Use scandir instead of opendir to ensure alphabetical order. --- lib/pico.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pico.php b/lib/pico.php index ffcd1a5..e0e285c 100644 --- a/lib/pico.php +++ b/lib/pico.php @@ -359,8 +359,8 @@ class Pico protected function get_files($directory, $ext = '') { $array_items = array(); - if ($handle = opendir($directory)) { - while (false !== ($file = readdir($handle))) { + if ($files = scandir($directory)) { + foreach ($files as $file) { if (in_array(substr($file, -1), array('~', '#'))) { continue; } @@ -375,7 +375,6 @@ class Pico } } } - closedir($handle); } return $array_items;