Answer the question
In order to leave comments, you need to log in
How to pass an array to a template?
Laravel 5.4
Received data from the JSON cell database, using explode() transferred the string to an array:
$sql = $test->party;
$pieces = explode("|", $sql);
array:1[▼
0 => "Wlof"
1 => "Leso"
2 => "Dusy"
3 => "Vova"
4 => "Kosty"
5 => "Zola"
6 => "Wlof"
]
return view('welcome')>with([
'pieces'=>$pieces
]);
@if(in_array($tery->nickname, $pieces, true))
...
@else
...
@endif
Answer the question
In order to leave comments, you need to log in
I decided to access the cell through the model and decode it in view.
@if(in_array($lottery->nickname, json_decode($test->party, true), true))
...
@else
...
@endif
return view('welcome')>with([
'pieces'=>$pieces
]);
You have the operator
> instead of -> written correctly before > with
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question