DEV Community

Morcos Gad
Morcos Gad

Posted on

New headline() method on Str class - laravel 8

Let's get started quickly - In the past

$str = 'welcome-to-here';
return Str::of($str)->replace('-', ' ')->title(); // Welcome To Here
Enter fullscreen mode Exit fullscreen mode

with headline()

$str = 'welcome-to-here';
return Str::of($str)->headline(); // Welcome To Here
return Str::headline($str); // Welcome To Here
Enter fullscreen mode Exit fullscreen mode

I hope you enjoy the code.

Discussion (0)