Laravel 9 PHP json_decode without quotes Example
May 03, 2022 . Admin
Hi Guys,
In this blog, I will show you an example of laravel 9 without decode " example. you can understand the concept of laravel 9 array json_decode example. We will talk about aravel json encode array jquery file.
If you created an array with a laravel controller and assign that array to a jquery variable then it looks like bellow with quotes. it seems it's not json array:
I will give you a simple solution. we will use code php and @json laravel 9 blade directive. let's see bellow two solution:
Step 1: Download LaravelLet us begin the tutorial by installing a new laravel application. if you have already created the project, then skip following step.
composer create-project laravel/laravel example-appStep 2: Create Controller:
php artisan make:controller DropzoneControllerapp/http/controller/DropzoneController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class DropzoneController extends Controller { /** * Generate Image upload View * * @return void */ public function dropzone() { $users = [ [ 'id' => 1, 'name' => 'Mark' ], [ 'id' => 2, 'name' => 'Pitter' ], [ 'id' => 3, 'name' => 'Michel' ] ]; return view('dropzone-view', compact('users')); } }Step 3: Create Blade File
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script type="text/javascript"> var users = @json($users); console.log(users); </script> </body> </html>
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script type="text/javascript"> var users = ; console.log(users); </script> </body> </html>Output:
It will help you...