How to print arrays inside array by Laravel blade?
My function returns an array to a variable in laravel blade page like this :
Array
(
[id] => 1
[name] => Enterpise
[children] => Array
(
[0] => Array
(
[id] => 2
[name] => name1
[children] => Array
(
[0] => Array
(
[id] => 5
[name] => name2
[children] =>
)
[1] => Array
(
[id] => 6
[name] => name3
[children] => Array
(
[0] => Array
(
[id] => 11
[name] => name4
[children] =>
)
.....
Now I want to print these values inside my page by using something like foreach
. Consider that their children's numbers are not specified, it is impossible to do that inside of my function. It is important to me to be done in blade. How can I do that?
In your blade files you can use any php functions like print_r()
.
Example:
{{ print_r($array) }}
As this is very old issue but I found json
directive very useful.
<pre>
<code>
@json($array);
</code>
</pre>