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}
]
@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?
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..
@braunson thax for your reply, but i got this error
htmlspecialchars() expects parameter 1 to be string, array given
how can solve that
@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?
i use collection to send data
$adminTracking = collect();
how can work with this situation
Have you tried to json_decode?
$myarray = json_decode($yourdata, true);
Then just loop the array.
Please or to participate in this conversation.