Laravel str padRight() function Example




Hi Guys,

In this blog,I will you how to use laravel str padRight() function example. We will show example of padRight function in laravel.The Str::padRight method wraps PHP's str_pad function, padding the right side of a string with another string until the final string reaches a desired length

Here, I will give you full example for simply str padRight() 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()


$converted1 = str::padRight('James', 10, '-');


// output - 'James-----'

$converted2 = Str::padRight('James', 10);


// output - 'James '





'James '

It Will help you...

#Laravel 8

#Laravel 7


#Laravel 6