Hello Devs, 

In this tutorial, we will learn Laravel str kebab() function Example

In this section, we will see an example of the kebab function in laravel.the str::kebab method converts the given string to kebab_case.

Follow this step-by-step guide below. 


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"


May this example help you.