src/Matchers/RepeatMatch.php
protected static function group($string)
    {
        $grouped = [];
        $chars = str_split($string);

        $prevChar = null;
        $i = 0;
        foreach ($chars as $char) {
            if ($prevChar === $char) {
                $grouped[$i - 1] .= $char;
            } else {
                $grouped[$i] = $char;
                ++$i;
                $prevChar = $char;
            }
        }

        return $grouped;
    }
protected static function group($string)
    {
        $grouped = [];
        $chars = str_split($string);

        $prevChar = null;
        $i = 0;
        foreach ($chars as $char) {
            if ($prevChar === $char) {
                $grouped[$i - 1] .= $char;
            } else {
                $grouped[$i] = $char;
                ++$i;
                $prevChar = $char;
            }
        }

        return $grouped;
    }
protected static function group ( $ string ) { $ grouped = [ ] ; $ chars = str_split ( $ string ) ; $ prevChar = null ; $ i = 0 ; foreach ( $ chars as $ char ) { if ( $ prevChar === $ char ) { $ grouped [ $ i - 1 ] .= $ char ; } else { $ grouped [ $ i ] = $ char ; ++ $ i ; $ prevChar = $ char ; } } return $ grouped ; }
Group input by repeated characters.

@param string $string

@return array
Group input by repeated characters .