Hello Friends 👋,
Welcome To Infinitbility! ❤️
Laravel provide multiple methods to change string or text case, here you get example convert text into title, uppercase, lowercase, ucfirst ( first char capitalize ).
Let’s start today topic Laravel change string case or how to change text case in laravel
Table of content
- Laravel titleCase
- Laravel ucfirst
- Laravel uppercase
- Laravel lowercase
Laravel titleCase
Laravel provide Str::title()
helper to create text in title case. in title case every first char of word are capitalize.
1use Illuminate\Support\Str;23$converted = Str::title('a nice title uses the correct case');45// A Nice Title Uses The Correct Case
Laravel ucfirst
Laravel provide Str::ucfirst()
helper to create text or string in uc first case. basically ucfirst means first char of first word is capital.
1use Illuminate\Support\Str;23$string = Str::ucfirst('foo bar');45// Foo bar
Laravel uppercase
Laravel provide Str::upper()
helpe to make text or string in uppercase.
1use Illuminate\Support\Str;23$string = Str::upper('infinitbility');45// INFINITBILITY
Laravel lowercase
Laravel not provide any helper to make text or string in lowercase but php provide strtolower()
method and we can also use in laravel.
1$string = strtolower('INFINITBILITY');23// infinitbility
Thanks for reading…
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.