Laravel str kebab() function Example

Laravel 6 , Laravel , Laravel 7 , Laravel 8

Nicesnippets

1453

10-09-2020


Laravel str kebab() function Example

Hi Guys,

In this blog,I will you how to use laravel str kebab() function example. We will show example of kebab function in laravel.the str::kebab method converts the given string to kebab_case.

Here, I will give you full example for simply str kebab() method in laravel as bellow.

Example


<?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()

{

$converted1 = Str::kebab('fooBar');

dd($converted1);

// output - foo-bar

$converted2 = Str::kebab('niceBlog');

dd($converted2);

//nice-blog

}

}

Output

"foo-bar"

"nice-blog"

It Will help you...


Recommended Posts