这个网站有一位朋友让我做一些改动。它使用Laravel框架。
我已经进行了一些数据库调用以获取一些数据,但是当我尝试合并另一个数组中的数据时,没有任何结果。这里似乎有什么问题?
public function show_opfolgningsoversigt() {
$complete = array();
$surveys = DB::table('surveys')->where('company_id', \Auth::user()->company_id)->get();
foreach($surveys as $survey) {
$questions = DB::table('questions')->where('survey_id', $survey->id)->get();
foreach($questions as $question) {
$answers = DB::table('answers')->where('question_id', $question->id)->get();
foreach($answers as $answer) {
array_merge($complete, array("recipient" => $answers->recipient_id, "followup" => $answers->followup);
}
}
}
$followups = $complete;
return view('survey.opfolgningsoversigt')->with('followups', $followups);
}
除$ complete之外的所有变量都输出它应该的内容。这意味着$ answers-> recipient_id和$ answers-> followup返回int。
答案 0 :(得分:3)
array_merge返回一个数组,在你的代码中你不使用返回的结果。
$complete = array_merge($complete, array("recipient" => $answers->recipient_id, "followup" => $answers->followup);
可能是你想要实现的目标。