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

        $between2 = Str::between('This is a Car','This','a');
        print_r($between2);
        // output - is
    }
}

May this help you.