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


solution

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

dd($converted1);

// output -  Foo bar



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

dd($converted2);

//Nice Blog


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::ucfirst('fooBar');
        dd($converted1);
        // output -  Foo bar

       $converted2 = Str::ucfirst('niceBlog');
        dd($converted2);
        //Nice blog
    }
}

May this example help you.