ItSolutionStuff.com

Laravel Convert String to Lowercase Example

By Hardik Savani • November 5, 2023
Laravel

Hey Friends,

Now, let's see an example of laravel string to lowercase. if you want to see an example of how to convert string to lowercase in laravel then you are in the right place. This post will give you a simple example of laravel convert string to lowercase. you can see laravel str lower helper.

Certainly! In Laravel, you can also use the Str::lower() method from the Illuminate\Support\Str class to convert a string to lowercase. Here's how you can do it.

Make sure you've included the use Illuminate\Support\Str; statement at the top of your file to import the Str class before using the Str::lower() method. This method provides the same functionality as the strtolower() function but is provided as a part of Laravel's helper methods.

let's see a simple example:

Laravel String to Lowercase in Controller

you can use it with controller like this way:

Controller Code:

<?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 = 'LARAVEL 10';

$lower = Str::lower($string);

dd($lower);

}

}

Output:

laravel 10

Laravel String to Lowercase in Blade File

you can use it with blade file like this way:

Blade File Code:

<p>{{ Str::lower('LARAVEL 10') }}</p>

Output:

laravel 10

I hope it can help you...

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Replace String in Laravel?

Read Now →

How to Install and Setup Supervisor in Ubuntu for Laravel?

Read Now →

Laravel String Contains Case Insensitive Example

Read Now →

Laravel Stripe Checkout Payment Integration Example

Read Now →

How to Convert String to Array Conversion in Laravel?

Read Now →

How to Add Dynamic Carousel Slider in Laravel?

Read Now →

How to Install and Use Laravel Debugbar?

Read Now →

Laravel Delete All Records Older Than 7 Days Example

Read Now →

How to Generate a Dropdown List of Timezone in Laravel?

Read Now →

How to use Bootstrap Icons in Laravel Vite?

Read Now →

How to Install Sweetalert2 in Laravel 10 Vite?

Read Now →

Laravel 10 Send Email using Queue Example

Read Now →