我想显示给定的数组,但我似乎无法让我的头围绕它的尺寸。我从一个excel工作表中导出数据然后阵列。
<?php
Excel::selectSheets('active_transport_sheet_1');
$reader->formatdates(true, 'd-m-Y');
$data = $reader->get(array('project_status', 'event_area', 'date_of_event', 'area_to_split',
'planned_split', 'actual_staff_on_split_requiring_transport', 'vehicle_type_required',
'project_number', 'event_name', 'driver_responsible_person',
'hire_stauts', 'shift_start_time', 'departure_date', 'departure_time'))
->toArray();
$this->data = json_encode($data);
$this->data = json_decode($this->data, true);
产量
视图
<div class="panel-body">
@foreach ($sheet as $sheets)
{{$sheets->date_of_event}}
@endforeach
</div>
错误
“试图让非对象的属性(查看:C:\ XAMPP \ htdocs中\墙板\资源\意见\板\ viewexcel.blade.php)”
<div class="panel-body">
@foreach ($sheet as $sheets)
{{$sheets->date_of_event}}
@endforeach
</div>
在上面的代码中,您试图访问一个对象{{$sheets->date_of_event}}
但它的数组。因此,尝试$sheets['date_of_event']
因此,完整的代码
<div class="panel-body">
@foreach ($sheet as $sheets)
{{$sheets['date_of_event']}}
@endforeach
</div>