In this tutorial, we will learn Laravel str padRight() function Example



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()
    {
        $converted1 = str::padRight('James', 10, '-');
        \Log::info($converted1);
        // output - 'James-----'

        $converted2 = Str::padRight('James', 10);
        \Log::info($converted2);
        // output - 'James     '
    }
}


May this example help you.