Hello Devs, 

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

The Str::camel method converts the given string to camelCase.

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()
    {
        $camel1 = Str::camel('foo_bar');
        
        print_r($camel1);
        // output - fooBar

        $camel2 = Str::camel('nice_game');
        
        print_r($camel2);
        // output - niceGame

        $camel3 = Str::camel('super_code');

        print_r($camel3);
        // output - superCode

    }
}


Output: 

fooBar
niceGame
superCode


May this example help you.