public function toTitleCase($ignore = null)
    {
        return $this->newSelf(preg_replace_callback
        (
            '/([\S]+)/u',
            function ($match) use ($ignore)
            {
                if ($ignore && in_array($match[0], $ignore, true))
                {
                    return $match[0];
                }
                else
                {
                    return (string)$this->newSelf($match[0])
                    ->toLowerCase()->upperCaseFirst();
                }
            },
            (string)$this->trim()
        ));
    }
public function toTitleCase($ignore = null)
    {
        return $this->newSelf(preg_replace_callback
        (
            '/([\S]+)/u',
            function ($match) use ($ignore)
            {
                if ($ignore && in_array($match[0], $ignore, true))
                {
                    return $match[0];
                }
                else
                {
                    return (string)$this->newSelf($match[0])
                    ->toLowerCase()->upperCaseFirst();
                }
            },
            (string)$this->trim()
        ));
    }
public function toTitleCase ( $ ignore = null ) { return $ this -> newSelf ( preg_replace_callback ( '/([\S]+)/u' , function ( $ match ) use ( $ ignore ) { if ( $ ignore && in_array ( $ match [ 0 ] , $ ignore , true ) ) { return $ match [ 0 ] ; } else { return ( string ) $ this -> newSelf ( $ match [ 0 ] ) -> toLowerCase ( ) -> upperCaseFirst ( ) ; } } , ( string ) $ this -> trim ( ) ) ) ; }
Returns a trimmed string with the first letter of each word capitalized.

Also accepts an array, $ignore, allowing you to
list words not to be capitalized.

@param  array|null $ignore An array of words not to capitalize

@return static
Returns a trimmed string with the first letter of each word capitalized .