Laravel print array in blade php
From your question it appears as if you want to output the array for debugging purposes which as I have commented you can simply use <?php
and ?>
tags within your blade templates.
<?php dd($array); ?>
However, blade has a raw output tag pair which is {!!
and !!}
.
Once you're ready to display the output of your directory structure you should assign it to your view.
There are 2 quick ways of using it either with Reflection; inside your controller:
class WatchController extends Controller{ public function index(\Illuminate\Filesystem\Filesystem $filesystem) { $files = $filesystem->allFiles($watchFolderPath); // Your code. return view('name', ['files' => $files]); }}
Or to call it from the container:
class WatchController extends Controller{ public function index() { $files = app('files')->allFiles($watchFolderPath); // Your code. return view('name', ['files' => $files]); }}
Also you should be using the Filesystem, there is no need to reinvent the wheel – You should read the manual.