In this tutorial you will learn about the Laravel str studly() function Example and its application with practical example.
In this article, I’ll show you how to use laravel Str::studly method with example. We will show example of Str::studly method in laravel. In this tutorial, we will use Str::studly method to convert given string to Studly Case.
Laravel Str::studly method
The Str::studly method converts the given string to StudlyCase.
Example:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Controllers\FileController; use Illuminate\Support\Str; class HomeController extends Controller { /** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index() { $studly1 = Str::studly('foo_bar'); print_r($studly1); // output - FooBar $studly2 = Str::studly('nice_game'); print_r($studly2); // output - NiceGame $studly3 = Str::studly('super_code'); print_r($studly3); // output - SuperCode } } |
Output:-
1 2 3 |
FooBar NiceGame SuperCode |