public static function get_files($directory, $ext = '')
    {
        $array_items = array();
        if($handle = opendir($directory)){
            while(false !== ($file = readdir($handle))){
                if($file != "." && $file != ".."){
                    if(is_dir($directory. "/" . $file)){
                        $array_items = array_merge($array_items, self::get_files($directory. "/" . $file, $ext));
                    } else {
                        $file = $directory . "/" . $file;
                        if(!$ext || strstr($file, $ext)) $array_items[] = preg_replace("/\/\//si", "/", $file);
                    }
                }
            }
            closedir($handle);
        }
        return $array_items;
    }
public static function get_files($directory, $ext = '')
    {
        $array_items = array();
        if($handle = opendir($directory)){
            while(false !== ($file = readdir($handle))){
                if($file != "." && $file != ".."){
                    if(is_dir($directory. "/" . $file)){
                        $array_items = array_merge($array_items, self::get_files($directory. "/" . $file, $ext));
                    } else {
                        $file = $directory . "/" . $file;
                        if(!$ext || strstr($file, $ext)) $array_items[] = preg_replace("/\/\//si", "/", $file);
                    }
                }
            }
            closedir($handle);
        }
        return $array_items;
    }
public static function get_files ( $ directory , $ ext = '' ) { $ array_items = array ( ) ; if ( $ handle = opendir ( $ directory ) ) { while ( false !== ( $ file = readdir ( $ handle ) ) ) { if ( $ file != "." && $ file != ".." ) { if ( is_dir ( $ directory . "/" . $ file ) ) { $ array_items = array_merge ( $ array_items , self :: get_files ( $ directory . "/" . $ file , $ ext ) ) ; } else { $ file = $ directory . "/" . $ file ; if ( ! $ ext || strstr ( $ file , $ ext ) ) $ array_items [ ] = preg_replace ( "/\/\//si" , "/" , $ file ) ; } } } closedir ( $ handle ) ; } return $ array_items ; }
Helper function to recusively get all files in a directory

@param string $directory start directory
@param string $ext optional limit to file extensions
@return array the matched files
Helper function to recusively get all files in a directory