public static function get_dirArray($dir, $filenameKey = false, $filter = null, $positive = false)
    {
        /*
         * Normalize the Filter.
         */
        if (empty($filter)) {
            $filter = array('.', '_');
        } elseif(is_object($filter)) {
            $filter = self::ar($filter, null, true);
        } elseif(!is_array($filter)) {
            $filter = array($filter);
        }

        if ($handle = opendir($dir)) {
            $r = array();
            $i = 0;
            while (false !== ($file = readdir($handle))) {
                $ok = !$positive;
                if (!empty($filter)) {
                    foreach ($filter as $f) {
                        if ($positive && strpos($file, $f) === 0) {
                            $ok = true;
                            break;
                        } elseif(!$positive && strpos($file, $f) === 0) {
                            $ok = false;
                            break;
                        }
                    }
                }
                if (!$ok) {
                    continue;
                }

                $k = $filenameKey ? $file : $i;
                $r[$k] = $file;
                $i++;
            }
            return $r;
        } else {
            return false;
        }
    }
public static function get_dirArray($dir, $filenameKey = false, $filter = null, $positive = false)
    {
        /*
         * Normalize the Filter.
         */
        if (empty($filter)) {
            $filter = array('.', '_');
        } elseif(is_object($filter)) {
            $filter = self::ar($filter, null, true);
        } elseif(!is_array($filter)) {
            $filter = array($filter);
        }

        if ($handle = opendir($dir)) {
            $r = array();
            $i = 0;
            while (false !== ($file = readdir($handle))) {
                $ok = !$positive;
                if (!empty($filter)) {
                    foreach ($filter as $f) {
                        if ($positive && strpos($file, $f) === 0) {
                            $ok = true;
                            break;
                        } elseif(!$positive && strpos($file, $f) === 0) {
                            $ok = false;
                            break;
                        }
                    }
                }
                if (!$ok) {
                    continue;
                }

                $k = $filenameKey ? $file : $i;
                $r[$k] = $file;
                $i++;
            }
            return $r;
        } else {
            return false;
        }
    }
public static function get_dirArray ( $ dir , $ filenameKey = false , $ filter = null , $ positive = false ) { /*
         * Normalize the Filter.
         */ if ( empty ( $ filter ) ) { $ filter = array ( '.' , '_' ) ; } elseif ( is_object ( $ filter ) ) { $ filter = self :: ar ( $ filter , null , true ) ; } elseif ( ! is_array ( $ filter ) ) { $ filter = array ( $ filter ) ; } if ( $ handle = opendir ( $ dir ) ) { $ r = array ( ) ; $ i = 0 ; while ( false !== ( $ file = readdir ( $ handle ) ) ) { $ ok = ! $ positive ; if ( ! empty ( $ filter ) ) { foreach ( $ filter as $ f ) { if ( $ positive && strpos ( $ file , $ f ) === 0 ) { $ ok = true ; break ; } elseif ( ! $ positive && strpos ( $ file , $ f ) === 0 ) { $ ok = false ; break ; } } } if ( ! $ ok ) { continue ; } $ k = $ filenameKey ? $ file : $ i ; $ r [ $ k ] = $ file ; $ i ++ ; } return $ r ; } else { return false ; } }
returns an array of files in a specific folder, excluding files starting with . or _

The default filter can be adjusted as a third parameter.
Accepted is an array with the amount of chars that will be filtered at the beginning
of the file or folder name on the first index. The second index have to be another
array containing strings that are not accepted.

@access public
@param  string  $dir         the directory.
@param  mixed   $filenameKey set true to use the filename as array key.
@param  array   $filter      an array with strings. Files starting with this string will be ignored.
@param  boolean $positive    set true to invert the filter. Only files not starting
with the filter string will be ignored

@return array
returns an array of files in a specific folder excluding files starting with . or _