How to Capitalize First Letter of String in Laravel

  Dec 2023
  ITSolutionsGuides
  Category: Laravel
How to Capitalize First Letter of String in Laravel

Hi Developers,

Lets see How to Capitalize First Letter of String in Laravel. To capitalize the text we will use the Str::ucfirst() helper function for making the text capital. The Str::ucfirst() will only capitalize the first letter of the string. The Str::ucfirst() helper function will only capitalize the first letter of the string only. Str::ucfirst() helper function will allows the user to convert the string into the uppercase. Sometime while creating any dynamic website we need to set some content as the uppercase content the user may enter the value as the lowercase. To avoid this we need to use the Str::ucfirst() helper function to cnvert the string . so lets see How to Capitalize First Letter of String in Laravel.

Learn capitalizing the first letter of a string in Laravel effortlessly. Elevate your string manipulation skills for cleaner, more professional outputs

Let's Start Coding

To capitalize any string in the controller we should use the Str::ucfirst() helper function for capitalizing the content in the controller file. We can also use this funtion before storing the data in the database. The output for the below code will be ,

Output: Follow ITSolutionsGuides for more informations

<?php
     
namespace App\Http\Controllers;
    
use Illuminate\Http\Request;
use Illuminate\Support\Str;
    
class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
    	$string = 'follow ITSolutionsGuides for more informations';
	$ucfirstString = Str::ucfirst($string);
  
        dd($ucfirstString);
    }
}

Let's Start Coding

For capitalize the content in the blade file we should follow the following syntax. The output for the below code will be ,

Output: Follow ITSolutionsGuides for more informations

<p>{{ Str::ucfirst("Follow ITSolutionsGuides for more informations") }}</p>

We hope it helps everyone. Thanks for supporting ITSolutionsGuides and keep supporting us also follow us in social media platforms.

Subscribe for NewsLetter

Be the first to know about releases and tutorial news and solutions.

We care about your data in our privacy policy.

ITSolutionsGuides

ITSolutionsGuides was started mainly to provide good and quality web solutions for all the developers. We provide tutorials to support all the developers and also we try to provide solutions to the errors we face while coding.

Contact US

ITSolutionsGuides, provide users with an easy-to-use form to reach out for support or inquiries.

whatsapp  gmail  instagram-new--v1  facebook-circled  twitter-circled  linkedin  github  pinterest 

Copyright © 2023 - 2024 All rights reserved | ITSolutionsGuides