0
我嘗試通過多維數組來查看。但是,當我嘗試打印它會給我錯誤。以下是代碼和錯誤。如何通過laravel blade中的多維數組?
控制器的文件:
foreach($countrygroup as $val){
//$userArr[] = $val->userid;
$users = DB::table('timelines')->where('id', '=', $val->userid)->first();
$userArr[$val->userid]['name'] = $users->name;//$users->name;
$userArr[$val->userid]['avatar'] = $users->avatar_id;
//$userArr[$val->userid]['image']=$users->image;
}
//echo '<pre>'; print_r($userArr); die();
return $theme->scope('groups/country', compact('userArr','trending_tags','countrygroupnamee'))
->render();
刃文件代碼:
@foreach($userArr as $users)
<h2>{{ $users}}</h2>
@endforeach
感謝
在foreach循環中查詢數據庫? Ouch ... – Eric