How to Remove Double Quotes From a String in Laravel?
Oct 14, 2022 . Admin

Hello Friends,
In this quick example, let's see how to remove double quotes from a string in laravel. I would like to share with you add or remove quotes double to string in laravel. you will learn to remove double quotes from string code examples in laravel. if you have a question about how to remove double or single quotes from a string in laravel then I will give a simple example with a solution. Alright, let’s dive into the steps.
You can use this example with the versions of laravel 6, laravel 7, laravel 8, and laravel 9.
You have just to follow the below step and you will get the layout as below:
Step 1: Install LaravelThis is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:
composer create-project laravel/laravel example-appStep 2: Create Format Route web.php
<?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\RemoveQuotesController; /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */ Route::get('/remove/quotes', [RemoveQuotesController::class,'removeQuotes']);Step 3: Create RemoveQuotesController
we will create RemoveQuotesController with Str::replace() method to replace string. so you can see the below code with output:
php artisan make:controller RemoveQuotesControllerApp\Http\Controllers\RemoveQuotesController
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class RemoveQuotesController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function removeQuotes() { $str = 'Welcome to "Mywebtuts.com"'; dd(str_replace('"', '', $str)); } }Step 4: Start Development Server
Start the development server. Use the PHP artisan serve command and start your server:
php artisan serve
Now you are ready to run our example so run the below command to quick run.
http://localhost:8000/remove/quotesOutput:
Welcome to Mywebtuts.com
I hope it can help you...