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.
use Illuminate\Support\Str;
$converted = Str::title('a nice title uses the correct case');
// 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.
use Illuminate\Support\Str;
$string = Str::ucfirst('foo bar');
// Foo bar
Laravel uppercase
Laravel provide Str::upper()
helpe to make text or string in uppercase.
use Illuminate\Support\Str;
$string = Str::upper('infinitbility');
// 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.
$string = strtolower('INFINITBILITY');
// infinitbility
Thanks for reading…