// simple scandir example Array ( [0] => . [1] => .. [2] => .ICE-unix [3] => .Test-unix [4] => .X11-unix [5] => .XIM-unix [6] => .accept [7] => .accepted [8] => .apache-monitor [9] => .cache [10] => .class [11] => .classes [12] => .config [13] => .content [14] => .created [15] => .db2_convert [16] => .dba_insertion [17] => .dbx_convert [18] => .fac [19] => .factor [20] => .font-unix [21] => .ibase_pconnection [22] => .include [23] => .internal [24] => .lock [25] => .locked [26] => .mb_convert [27] => .multi [28] => .oauthexceptions [29] => .ob_iconv_handle [30] => .obj [31] => .parle_tokens [32] => .partition [33] => .post [34] => .proc-monitor_time [35] => .ptr [36] => .request [37] => .requests [38] => .res [39] => .reset [40] => .rfind [41] => .rindex [42] => .sys [43] => .system [44] => .uconvert [45] => TTYDEVS_12345678 [46] => hg_save_ssl [47] => hsperfdata_root [48] => kill_usage.lock [49] => lost+found [50] => lq-67c84d2b29df7 [51] => mysql.sock [52] => php0Pr5tR [53] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-lldpd.service-fxpupQ [54] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-lldpd.service-tH7VxR [55] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-named.service-70Sg05 [56] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-named.service-xxbScY [57] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-ntpd.service-Bib7id [58] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-ntpd.service-FiNfoX ) Array ( [0] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-ntpd.service-FiNfoX [1] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-ntpd.service-Bib7id [2] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-named.service-xxbScY [3] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-named.service-70Sg05 [4] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-lldpd.service-tH7VxR [5] => systemd-private-1ad2953e3cba4bfe8d759c45a6cc95fc-lldpd.service-fxpupQ [6] => php0Pr5tR [7] => mysql.sock [8] => lq-67c84d2b29df7 [9] => lost+found [10] => kill_usage.lock [11] => hsperfdata_root [12] => hg_save_ssl [13] => TTYDEVS_12345678 [14] => .uconvert [15] => .system [16] => .sys [17] => .rindex [18] => .rfind [19] => .reset [20] => .res [21] => .requests [22] => .request [23] => .ptr [24] => .proc-monitor_time [25] => .post [26] => .partition [27] => .parle_tokens [28] => .obj [29] => .ob_iconv_handle [30] => .oauthexceptions [31] => .multi [32] => .mb_convert [33] => .locked [34] => .lock [35] => .internal [36] => .include [37] => .ibase_pconnection [38] => .font-unix [39] => .factor [40] => .fac [41] => .dbx_convert [42] => .dba_insertion [43] => .db2_convert [44] => .created [45] => .content [46] => .config [47] => .classes [48] => .class [49] => .cache [50] => .apache-monitor [51] => .accepted [52] => .accept [53] => .XIM-unix [54] => .X11-unix [55] => .Test-unix [56] => .ICE-unix [57] => .. [58] => . ) // output //Array //( // [0] => . // [1] => .. // [2] => bar.php // [3] => foo.txt // [4] => somedir //) //Array //( // [0] => somedir // [1] => foo.txt // [2] => bar.php // [3] => .. // [4] => . //) //directory to atrray //Output //Array //(Easy way to get rid of the dots that scandir() picks up in Linux environments: