基本上我想做这样的事情:
$arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
$avg = array_sum($arr) / count($arr);
$callback = function($val){ return $val < $avg };
return array_filter($arr, $callback);
Run Code Online (Sandbox Code Playgroud)
这有可能吗?计算匿名函数之外的变量并在里面使用它?
我正在使用Laravel 4开发一个网站,并希望在测试期间发送自己的临时电子邮件,但似乎发送电子邮件的唯一方法是通过视图.
可以这样做吗?
Mail::queue('This is the body of my email', $data, function($message)
{
$message->to('foo@example.com', 'John Smith')->subject('This is my subject');
});
Run Code Online (Sandbox Code Playgroud)