src/Manipulator.php
public function nthCharacter(int $nth, \Closure $closure) : Manipulator
    {
        $count = 1;
        $modifiedString = '';

        foreach (str_split($this->string) as $character) {
            $modifiedString .= $count === $nth ? $closure($character) : $character;
            $count++;
        }

        return new static($modifiedString);
    }
public function nthCharacter(int $nth, \Closure $closure) : Manipulator
    {
        $count = 1;
        $modifiedString = '';

        foreach (str_split($this->string) as $character) {
            $modifiedString .= $count === $nth ? $closure($character) : $character;
            $count++;
        }

        return new static($modifiedString);
    }
public function nthCharacter ( int $ nth , \ Closure $ closure ) : Manipulator { $ count = 1 ; $ modifiedString = '' ; foreach ( str_split ( $ this -> string ) as $ character ) { $ modifiedString .= $ count === $ nth ? $ closure ( $ character ) : $ character ; $ count ++ ; } return new static ( $ modifiedString ) ; }
Perfrom an action on the nth character.

@param  int
@param  Closure
@return object|Manipulator
Perfrom an action on the nth character .