Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ethar's avatar
Level 5

print array in blade

how can print this array in blade (print data in foreach and value in another foreach)

[
{"09-08-2020": 4},
{"10-08-2020": 4},
{"11-08-2020": 4},
{"12-08-2020": 4},
{"13-08-2020": 0},
{"14-08-2020": 0}
]
0 likes
7 replies
GeordieJackson's avatar

@ethar

how can print this array in blade

It can be done in lots of ways.

Do you want to use blade directives or is it Json that you want to display using Vue, React, jQuery, etc.?

Or something else?

What have you done so far?

1 like
Braunson's avatar

The array you posted is in JSON format, if it was to be a PHP array, you could loop it out like this:

@foreach ($array as $k => $v)
    Key: {{ $k }} - Value:{{ $v }}<br />
@endforeach

Which will result in something like this..

Key: 09-08-2020 - Value:4
Key: 10-08-2020 - Value:4
Key: 11-08-2020 - Value:4
etc..
1 like
ethar's avatar
Level 5

@braunson thax for your reply, but i got this error htmlspecialchars() expects parameter 1 to be string, array given how can solve that

1 like
GeordieJackson's avatar

@ethar

@geordiejackson I mentioned in the title, I want to use blade directives

The array you posted is in JSON format.

How is it getting to your blade and is it in JSON format when you're using it?

1 like
ethar's avatar
Level 5

i use collection to send data $adminTracking = collect(); how can work with this situation

jlrdw's avatar

Have you tried to json_decode?

$myarray = json_decode($yourdata, true);

Then just loop the array.

1 like

Please or to participate in this conversation.