In this tutorial you will learn about the Laravel str is() function Example and its application with practical example.
In this article, I’ll show you how to use laravel Str::is function with example. We will show example of laravel Str::is function in laravel. In this tutorial, we will check match test string with specified pattern.
Laravel Str::is method
The Str::is method is sued to determines if a given string matches with given pattern. Asterisks may be used to indicate wildcard.
Example:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?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('exam*', 'example'); dd($is1); // output - true $is2 = Str::is('tea*', 'tester'); dd($is2); // output - false } } |
Output:-
1 2 |
true false |