Laravel str limit() function Example

10-Apr-2023

.

Admin

Hi Guys,

In this limit blog,I will you how to use laravel str limit() function example. We will show example of limit function in laravel.The limit method truncates the given string to the specified length.

Here, The Str::limit method determines if a given string matches a given pattern. Asterlimitks may be used to indicate wildcards

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()

{

$limit1 = Str::limit('The quick brown fox jumps over the lazy dog', 20);

\Log::info($limit1);

// output - The quick brown fox...

$limit2 = Str::limit('This is Car',7);

\Log::info($limit2);

// output - This is....

}

}

Output

The quick brown fox...

This is....

It Will help you...

#Laravel 8

#Laravel 7

#Laravel

#Laravel 6