In this tutorial you will learn about the Laravel str padRight() function Example and its application with practical example.
In this article, I’ll show you how to use laravel str padRight() function with example. We will show example of str padRight() function in laravel. In this tutorial, we will use str padRight() function to add padding to the right side of a string with another string until the final string reaches a desired length.
Laravel Str::padRight method
The Str::padRight method add padding to the right side of a string with another string until the final string reaches a desired length.
Example:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?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() { $converted1 = str::padRight('steve', 10, '*'); echo $converted1."<br>"; $converted2 = Str::padRight('steve', 10); echo $converted2."<br>"; } } |
Output:-
1 2 |
steve***** steve |