Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

concat in url in larvel

Concatenate parameters in URL in Laravel

In this tutorial, I will give you an example of “How to Concatenate parameters in URL 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 :

Concatenate parameters in URL in Laravel

Concatenate parameters in URL in Laravel

In this example, we will pass id on web.php, and we Concat user email, we can concatenate multiple parameters to the end of a route, and get these parameters in Controller using strpos() function in Laravel.

strrpos in php :

The strrpos() function finds the position of the last occurrence of a string inside another string.

Note: The strrpos() function is case-sensitive.


concatenate to the end of a route

      <div class="container">
         <h3>Concat and pass parameters in url | Laravel</h3>
         <table class="table">
             @foreach($data as $key => $data)
                  <td>{{ $key+1 }}</td>
                  <a href="{{route('concat.view',$data->id . '-' .$data->name. '-' .$data->email)}}">View</a>


#concat and pass parameter in url Example

App\Http\Controllers \TestController.php


namespace App\Http\Controllers;

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

class TestController extends Controller

  #Concat parameter in url Example
  public function concatparameter(){
    $data = TestModel::all();
    return view('list',compact('data'));

  #Get parameters from url
  public function concatparameterview($id){
     $id = substr($id, strrpos( $id, '-'));
     $email = substr($id,1);

parameters concat in laravel

pass parameter in url laravel

Finally, In this tutorial, we learned, How to Concatenate parameters in URL in Laravel.

Also Read: How to add dynamic meta tags in Laravel 8.