How to Get Parts of a String in Laravel
In this lesson, we are going to see how to get parts of a string in Laravel, the substr helper method is used to retrieve a portion of a string.
The Str::substr helper method
The substr() method is used to retrieve a portion of a string by defining a start and an end argument.
use Illuminate\Support\Str;
$portion = Str::substr('Darija Coding', 0, 6);
echo $portion;
// Returns "Darija"