On Unix, every directory contains the directory . which is a reference to itself, and .., which is a reference to the parent directory. If you don't want to consider those, filter them out from the array.
(Note that "reference" is a bit vague, I think it's more like a hard link, but I'm not entirely sure).