尝试在laravel集合之外访问变量->每个 [英] Trying to access variable outside laravel collection->each
本文介绍了尝试在laravel集合之外访问变量->每个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试访问laravel collection->每个外部的变量,但我得到了..
I am trying to access variable outside laravel collection->each, but I get ..
Undefined variable: headers
这是我的代码:
public function bulkCoding(Request $request) {
Excel::load($request->file, function($reader) {
$headers = $reader->get()->first()->keys();
// Loop through all sheets
$reader->each(function($sheet) {
$headers->each(function ($title) {
dd($title);
});
});
});
}
推荐答案
您需要使用 use()
来
查看全文