In this tutorial, we will learn Laravel str limit() function Example


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....
    }
}

May this example help you.