In this tutorial, we will learn Laravel str endsWith() 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()
    {
        $endsWith1 = Str::endsWith('This is my name', 'name');
        
        print_r($endsWith1);
        // output - true

        $endsWith2 = Str::endsWith('This is a Car','is');
        
        print_r($endsWith2);
        // output - false
    }
}


May this example help you.