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

       $converted2 = Str::contains('This is dog', 'cow');
        dd($converted2);
        //output - false
    }
}


May this example help you.