php - Array from nlist() showing periods -


this question has answer here:

i using nlist() function phpseclib list contents of directory on remote server. result get. array ( [0] => newfile.txt [1] => . [2] => .. [3] => oldfile.txt [4] => readme.pdf ).

i have following files in folder.

1. newfile.txt 2. oldfile.txt 3. readme.pdf 

but, why putting . , .. in array? seems happen no matter directory in or how many items in directory.

. , .. magic, , exist in every folder. first refers current directory, second refers parent directory.

you can remove them results list http://php.net/array_diff

<? $arr = array('newfile.txt', '.', '..', 'oldfile.txt', 'readme.pdf'); $arr = array_diff($arr, array('.', '..')); print_r($arr) ?> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -