Showing posts with label example of afterLast function in laravel. Show all posts
Showing posts with label example of afterLast function in laravel. Show all posts

Laravel str afterLast() function Example

Laravel str afterLast() function

Hi Guys,

Today,I will learn 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.

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()
    {
        $slice = Str::afterLast('App\Http\Controllers\Controller', '\\');
        \Log::info($slice);
        //'Controller'
    }
}
Output
'Controller'

It Will help you...