Laravel Convert String to Lowercase Example
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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Replace String in Laravel?
- How to Install and Setup Supervisor in Ubuntu for Laravel?
- Laravel String Contains Case Insensitive Example
- Laravel Stripe Checkout Payment Integration Example
- How to Convert String to Array Conversion in Laravel?
- How to Add Dynamic Carousel Slider in Laravel?
- How to Install and Use Laravel Debugbar?
- Laravel Delete All Records Older Than 7 Days Example
- How to Generate a Dropdown List of Timezone in Laravel?
- How to use Bootstrap Icons in Laravel Vite?
- How to Install Sweetalert2 in Laravel 10 Vite?
- Laravel 10 Send Email using Queue Example