public static function printWords($words, $spaces = 8, $line = 80)
    {
        $typesCount = count($words);
        $ret = '';
        $j = 0;

        foreach ($words as $type => $wordsByType) {
            foreach ($wordsByType as $len => $wordsByLen) {
                $count = round(($line - $spaces) / ($len + 9)); // strlen("'' => 1, ") = 9
                $i = 0;

                foreach ($wordsByLen as $word) {
                    if ($i === 0) {
                        $ret .= str_repeat(' ', $spaces);
                    }
                    $ret .= sprintf('\'%s\' => %s, ', $word, $type);
                    if (++$i === $count) {
                        $ret .= "\n";
                        $i = 0;
                    }
                }

                if ($i !== 0) {
                    $ret .= "\n";
                }
            }

            if (++$j < $typesCount) {
                $ret .= "\n";
            }
        }

        // Trim trailing spaces and return.
        return str_replace(" \n", "\n", $ret);
    }
public static function printWords($words, $spaces = 8, $line = 80)
    {
        $typesCount = count($words);
        $ret = '';
        $j = 0;

        foreach ($words as $type => $wordsByType) {
            foreach ($wordsByType as $len => $wordsByLen) {
                $count = round(($line - $spaces) / ($len + 9)); // strlen("'' => 1, ") = 9
                $i = 0;

                foreach ($wordsByLen as $word) {
                    if ($i === 0) {
                        $ret .= str_repeat(' ', $spaces);
                    }
                    $ret .= sprintf('\'%s\' => %s, ', $word, $type);
                    if (++$i === $count) {
                        $ret .= "\n";
                        $i = 0;
                    }
                }

                if ($i !== 0) {
                    $ret .= "\n";
                }
            }

            if (++$j < $typesCount) {
                $ret .= "\n";
            }
        }

        // Trim trailing spaces and return.
        return str_replace(" \n", "\n", $ret);
    }
public static function printWords ( $ words , $ spaces = 8 , $ line = 80 ) { $ typesCount = count ( $ words ) ; $ ret = '' ; $ j = 0 ; foreach ( $ words as $ type => $ wordsByType ) { foreach ( $ wordsByType as $ len => $ wordsByLen ) { $ count = round ( ( $ line - $ spaces ) / ( $ len + 9 ) ) ; // strlen("'' => 1, ") = 9 $ i = 0 ; foreach ( $ wordsByLen as $ word ) { if ( $ i === 0 ) { $ ret .= str_repeat ( ' ' , $ spaces ) ; } $ ret .= sprintf ( '\'%s\' => %s, ' , $ word , $ type ) ; if ( ++ $ i === $ count ) { $ ret .= "\n" ; $ i = 0 ; } } if ( $ i !== 0 ) { $ ret .= "\n" ; } } if ( ++ $ j < $ typesCount ) { $ ret .= "\n" ; } } // Trim trailing spaces and return. return str_replace ( " \n" , "\n" , $ ret ) ; }
Prints an array of a words in PHP format.

@param array $words  the list of words to be formatted
@param int   $spaces the number of spaces that starts every line
@param int   $line   the length of a line

@return string
Prints an array of a words in PHP format .