我正在做一个名为FUND的crud,在那里我可以使用PHP内爆方法存储很多东西以及数组。在那个数组中,我存储了一些基金Id。下面是数组创建代码:
<div class="custom-checkbox">
<label for="receive[]">Select Receive Funds</label>
@foreach($funds as $fund)
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" name="receive[]" id="{{$fund->id}}" value="{{$fund->id}}">
<label for="{{$fund->id}}" class="custom-control-label">{{$fund->title}}</label>
</div>
@endforeach
以下是商店代码:
public function store(Request $request)
{
$request->validate([
'title'=>'required',
'image'=>'required',
'description',
'available'=>'required',
'buy'=>'required',
'account',
'receive',
]);
$image = $request->file('image');
$new_name = rand() . '.' . $image->getClientOriginalExtension();
$image->move(public_path('funds'), $new_name);
$form_data = array(
'title'=>$request->title,
'image'=>$new_name,
'description'=>$request->description,
'available'=>$request->available,
'buy'=>$request->buy,
'buyrate'=>$request->buyrate,
'sellrate'=>$request->sellrate,
'account'=>$request->account,
'receive'=>implode(',', (array)($request->receive)),
);
Fund::create($form_data);
return redirect('/admin/fund');
}
我使用PHP分解方法在我的索引页上显示该数组。
$receive=[];
foreach($funds as $fund){
$receive = explode(",",$fund->receive);
}
正如我所提到的,我正在将基金ID存储在该数组中。因此,我想使用基金 ID 显示整行。为此,我使用以下查询:
但标题图像显示如下
我怎样才能在没有任何括号的情况下获得标题,图像和其他员工?
aluckdog
料青山看我应如是