如何在 Laravel 视图中排列来自@foreach 的数据

How to array data from @foreach in Laravel Views

我知道这是可能的,但我尝试从网上搜索,但我从未找到答案,所以如果有人知道如何使用 Laravel 将数据从@foreach 推送到数组,请查看帮我。提前致谢

这是代码

@foreach ($fields as $key => $rel)

 {{ $arrayData = array(

    'field_type' =>'$rel->field_type'
 )}}

@endforeach

我收到的错误是

helpers.php 第 519 行中的错误异常: htmlspecialchars() 期望参数 1 为字符串,给定数组 (View: C:\xampp\htdocs\fields.blade.php)

从 $rel->field_type

中删除引用
@foreach ($fields as $key => $rel)

 {{ $arrayData = array(

    'field_type' =>$rel->field_type
 )}}

@endforeach