str/Character.php
public static function each(string $str, callable $callable, string $encoding = null, ...$args) : string
    {
        if ($str === '') {
            return $str;
        }

        $result   = '';
        $encoding = $encoding ?: utils\Str::encoding($str);
        $length   = mb_strlen($str, $encoding);

        for ($idx = 0; $idx < $length; $idx++) {
            $result .= (string) call_user_func($callable, mb_substr($str, $idx, 1, $encoding), $idx, ...$args);
        }

        return $result;
    }
public static function each(string $str, callable $callable, string $encoding = null, ...$args) : string
    {
        if ($str === '') {
            return $str;
        }

        $result   = '';
        $encoding = $encoding ?: utils\Str::encoding($str);
        $length   = mb_strlen($str, $encoding);

        for ($idx = 0; $idx < $length; $idx++) {
            $result .= (string) call_user_func($callable, mb_substr($str, $idx, 1, $encoding), $idx, ...$args);
        }

        return $result;
    }
public static function each ( string $ str , callable $ callable , string $ encoding = null , ... $ args ) : string { if ( $ str === '' ) { return $ str ; } $ result = '' ; $ encoding = $ encoding ? : utils \ Str :: encoding ( $ str ) ; $ length = mb_strlen ( $ str , $ encoding ) ; for ( $ idx = 0 ; $ idx < $ length ; $ idx ++ ) { $ result .= ( string ) call_user_func ( $ callable , mb_substr ( $ str , $ idx , 1 , $ encoding ) , $ idx , ... $ args ) ; } return $ result ; }
Runs the given callable over each character in the given string and returns the resulting string.

The callable should accept two arguments (in this order):
- the character (multibyte string)
- the character's index (int).

Additional arguments may also be added and will be appended to the callable in the order given.
The callable must return either a string or a value castable to a string.

@param   string      $str        The string over which to run the callable.
@param   callable    $callable   The callable to apply.
@param   string|null $encoding   The encoding to use.
@param   mixed       ...$args    Additional arguments to pass to the callable.
@return  string                  The string after applying the callable to each of its characters.
Runs the given callable over each character in the given string and returns the resulting string .