dongyong5255
2016-10-21 12:12
浏览 492
已采纳

Laravel 5:未定义的变量return_array [重复]

I'm trying to get data with ajax call, and after sending the ajax call i want to store data in array, but I'm getting this error when I open the page.

Undefined variable: return_array

My function

public function findUser(Request $request) {
    $findUserInput = $request->get('name');
    $user = DB::table('users')
        ->where('name', $findUserInput)
        ->first();

    $data =  DB::select("SELECT * FROM users WHERE name='$user'");

    foreach ($data as $da) {
        $return_array[] = $da;
    } 

    return $return_array;      
}

Any ideas?

</div>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题