How to increment letters like numbers in Laravel

Increment letters like numbers in Laravel

In this tutorial, I will give you an example of the “How to Increment letters like numbers in Laravel“, So you can easily apply it with your laravel 5, laravel 6, laravel 7, and laravel 8 application.

First, what we’re doing here, This is the example :

Increment letters like numbers in laravel

Need of list Alphabetical (A-Z) in Laravel

Whenever we work on invoice or inventory applications in Laravel, Sometimes we need to show the sub-items or subcategories under the alphabet for better alignment of invoices.

In this example, We will get all data from table data from the database and show the sequence alphabetically instead of numbers in the blade file.

Database Table :

We have a test table in the database and we already stored some dummy data in this table using faker.

We created a model Test Table1, using this model we got all the data from the table.

Best way to list Alphabetical (A-Z) using PHP





 namespace App\Http\Controllers;

 use Illuminate\Http\Request;
 use App\Model\TestTable1;

 class TestController extends Controller

  #example of increment letter
  public function index(){
    $data = TestTable1::all();
    return view('incrementexample',compact('data'));


Now, you can see the output in the blade file, we have successfully implemented the list Alphabetical (a-z) using PHP in the Laravel application.

    <div class="container">
         <h3>Increment letters like numbers (a - z) in Laravel</h3>
         <table class="table">


               $albha = 'a'; $char < 'z';


               @foreach($data as $data)
                  <td><b>{{ $albha++ }}.</b></td>
Increment letters like numbers in laravel

If you want to capitalize the alphabet like (A-Z), just capitalize the alphabet string in code.


  $albha = 'A'; $char < 'Z';

Best way to list Alphabetical (A-Z) using PHP

In this article, we learned “Increment letters like numbers in Laravel”, I hope this article will help you with your Laravel application Project.

Also Read : Create a custom helper function in Laravel.

Hi, My name is Gaurav Pandey. I'm a Laravel developer, owner of 8Bityard. I live in Uttarakhand - India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Javascript, JQuery, Laravel, WordPress.