Skip to content

All topics  /  Laravel

Laravel str is() function Example

Laravel ·

Hi Guys,

In this blog,I will you how to use laravel str is() function example. We will show example of is function in laravel.The Str::is method to string matches a given pattern.

Here, The Str::is method determines if a given string matches a given pattern. Asterisks 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()
    {
        $is1 =  Str::is('nices*', 'nicesnippets');
        dd($is1);
        // output - true
        $is2 =  Str::is('itlogin*', 'itsolutionstuff');
        dd($is2);
        // output - false
    }
}

Output

true
false

It Will help you...