Laravel str afterLast() function Example

Admin   Laravel   353  2021-03-14 09:00:05

Hi Guys,

In this blog,I will you how to use laravel str afterLast() function example. We will show example of afterLast function in laravel.The Str::afterLast method returns everything after the last occurrence of the given value in a string. The entire string will be returned if the value does not exist within the string.

Here, I will give you full example for simply str afterLast() method in laravel as bellow.




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()


$slice = Str::afterLast('App\Http\Controllers\Controller', '\\');








It Will help you...