I'm new to PHP and Laravel, I have written a Controller which call a RestAPI. The API delivers following structure:
{
"platform": "Unix",
"hostname": "...",
"guid": "...",
"panel_version": "...",
"panel_revision": "...",
"panel_build_date": "...",
"panel_update_version": "",
"extension_version": "...",
"extension_release": "..."
}
i will pass this data into blade template like this;
return view('data', ['result' => $data]);
in blade php i made following:
<table>
<tr>
<td>platform</td>
<td>hostname</td>
<td>panel-version</td>
<td>build-date</td>
</tr>
@foreach ($result as $item)
<td>{{$item['platform']}}</td>
@endforeach
<tr>
</tr>
</table>
i dont know why, but i get an error "Trying to access array offset on value of type int" in the {{$item['id']}} row.
any suggestions to solve this problem?
I know there are some more questions about this, all ive tried did not helped me.
Thank you
best regards: Lars :)
-SOLVED-
json_decode($result, true)]
the "true" option must needed to be set
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.