How to Get Content between Two Strings in Laravel
In this lesson, we are going to see how to get content between two strings in Laravel, the between helper method is used to retrieve part of a string that appears between two other strings.
The Str::between helper method
The between() method is used to retrieve part of a string that appears between two other strings.
use Illuminate\Support\Str;
$website = 'http://www.website.com/posts/tech/all';
$part = Str::between($website, '/posts/', '/all');
echo $part;
// Returns "tech"