In this tutorial you will learn about the Laravel str contains() function Example and its application with practical example.
Laravel str contains() function Example
In this article, I’ll show you how to use laravel str contains() function with example. We will show example of str contains() function in laravel. In this tutorial, we will use str contains() function to check if a string contains any provided substring in it..
Laravel Str::contains() method
The Str::contains() method check if a string contains any substring in it. The Str::contains() method is str contains case insensitive.
Example:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?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() { $str1 = Str::contains('welcome to the world', 'world'); echo $str1."<br>"; $converted2 = Str::contains('this is laravel tutorial', 'teacher'); echo $str2."<br>"; } } |
Output:-
1 2 |
bool(true) bool(false) |