Laravel str endsWith() function Example

10-Apr-2023

.

Admin

Hi Guys,

In this blog,I will you how to use laravel str endsWith() function example. We will show example of endsWith function in laravel.The Str::endsWith method determines if the given string ends with the given value.

Here, I will give you full example for simply str endsWith() method in laravel as bellow.

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

}

}

Output

true

false

It Will help you...

#Laravel 8

#Laravel 7

#Laravel

#Laravel 6