Laravel str length() function Example

Laravel str length() function example. In this example, I explain how to find length of string in laravel. We will learn laravel str length() function. In this example, We will step by step to get length of string in laravel.

Laravel str length() function returns the length of the given string. Also, you can learn laravel str length() helper function.

Example

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Str;

class UserController extends Controller
{
    public function index(){

        $length = Str::length('Laravel');
        echo $length;
     }
}

routes/web.php

<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;


Route::get('users', [UserController::class,'index']);

I hope you understand laravel str length() function and it can help you..