How to use php array in json in laravel blade with @json

Admin   Laravel   513  2021-03-17 17:00:06

Hello Dev,

In laravel blade template provide @json directive. now you don't use json_encode() function in laravel blade template. instead of manually calling json_encode, you can use the @json blade directive. without using json_encode function how to print php array in laravel blade.




var app = <?php echo json_encode($myArray); ?>;


In Laravel Blade



var app = @json($myArray);

var app = @json($myArray, JSON_PRETTY_PRINT);


I hope it can help you...