public static function readWords(array $files)
    {
        $words = [];
        foreach ($files as $file) {
            $words = array_merge($words, file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
        }

        $types = [];

        for ($i = 0, $count = count($words); $i !== $count; ++$i) {
            $type = 1;
            $value = trim($words[$i]);

            // Reserved, data types, keys, functions, etc. keywords.
            foreach (static::$LABELS_FLAGS as $label => $flags) {
                if (strstr($value, $label) !== false) {
                    $type |= $flags;
                    $value = trim(str_replace($label, '', $value));
                }
            }

            // Composed keyword.
            if (strstr($value, ' ') !== false) {
                $type |= 2; // Reserved keyword.
                $type |= 4; // Composed keyword.
            }

            $len = strlen($words[$i]);
            if ($len === 0) {
                continue;
            }

            $value = strtoupper($value);
            if (! isset($types[$value])) {
                $types[$value] = $type;
            } else {
                $types[$value] |= $type;
            }
        }

        $ret = [];
        foreach ($types as $word => $type) {
            $len = strlen($word);
            if (! isset($ret[$type])) {
                $ret[$type] = [];
            }
            if (! isset($ret[$type][$len])) {
                $ret[$type][$len] = [];
            }
            $ret[$type][$len][] = $word;
        }

        return static::sortWords($ret);
    }
public static function readWords(array $files)
    {
        $words = [];
        foreach ($files as $file) {
            $words = array_merge($words, file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
        }

        $types = [];

        for ($i = 0, $count = count($words); $i !== $count; ++$i) {
            $type = 1;
            $value = trim($words[$i]);

            // Reserved, data types, keys, functions, etc. keywords.
            foreach (static::$LABELS_FLAGS as $label => $flags) {
                if (strstr($value, $label) !== false) {
                    $type |= $flags;
                    $value = trim(str_replace($label, '', $value));
                }
            }

            // Composed keyword.
            if (strstr($value, ' ') !== false) {
                $type |= 2; // Reserved keyword.
                $type |= 4; // Composed keyword.
            }

            $len = strlen($words[$i]);
            if ($len === 0) {
                continue;
            }

            $value = strtoupper($value);
            if (! isset($types[$value])) {
                $types[$value] = $type;
            } else {
                $types[$value] |= $type;
            }
        }

        $ret = [];
        foreach ($types as $word => $type) {
            $len = strlen($word);
            if (! isset($ret[$type])) {
                $ret[$type] = [];
            }
            if (! isset($ret[$type][$len])) {
                $ret[$type][$len] = [];
            }
            $ret[$type][$len][] = $word;
        }

        return static::sortWords($ret);
    }
public static function readWords ( array $ files ) { $ words = [ ] ; foreach ( $ files as $ file ) { $ words = array_merge ( $ words , file ( $ file , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ) ; } $ types = [ ] ; for ( $ i = 0 , $ count = count ( $ words ) ; $ i !== $ count ; ++ $ i ) { $ type = 1 ; $ value = trim ( $ words [ $ i ] ) ; // Reserved, data types, keys, functions, etc. keywords. foreach ( static :: $ LABELS_FLAGS as $ label => $ flags ) { if ( strstr ( $ value , $ label ) !== false ) { $ type |= $ flags ; $ value = trim ( str_replace ( $ label , '' , $ value ) ) ; } } // Composed keyword. if ( strstr ( $ value , ' ' ) !== false ) { $ type |= 2 ; // Reserved keyword. $ type |= 4 ; // Composed keyword. } $ len = strlen ( $ words [ $ i ] ) ; if ( $ len === 0 ) { continue ; } $ value = strtoupper ( $ value ) ; if ( ! isset ( $ types [ $ value ] ) ) { $ types [ $ value ] = $ type ; } else { $ types [ $ value ] |= $ type ; } } $ ret = [ ] ; foreach ( $ types as $ word => $ type ) { $ len = strlen ( $ word ) ; if ( ! isset ( $ ret [ $ type ] ) ) { $ ret [ $ type ] = [ ] ; } if ( ! isset ( $ ret [ $ type ] [ $ len ] ) ) { $ ret [ $ type ] [ $ len ] = [ ] ; } $ ret [ $ type ] [ $ len ] [ ] = $ word ; } return static :: sortWords ( $ ret ) ; }
Reads a list of words and sorts it by type, length and keyword.

@param string[] $files

@return array
Reads a list of words and sorts it by type length and keyword .