Search

Laravel 5.5 String Helper Method: title

November 30, 2017 —John Koster

This method will convert the given $value to look like a traditional print title. This method essentially will transform the entire $value to its lower cased equivalent and then uppercase the first character of each word it finds. This method may potentially affect the case of every character in the string.

#Signature

The signature of the title method is:

1public static function title(
2 $value
3 );

#Example Use

1use Illuminate\Support\Str;
2 
3// This Is A Title
4echo Str::title('THIS IS A TITLE');
5 
6// This Is A Title
7echo Str::title('this is a title');
8 
9// This Is A Title
10echo Str::title('ThIs Is a tItle');

#Global title_case Helper Function

The title_case helper function is a shortcut to calling Str::title. This function is declared in the global namespace.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.