Reputation: 165
Using an Excel library, how do I make function check_stuff
return false
when needed? As of right now, $this->check_stuff($path)
always returns true
. Keep in mind that I cannot modify class Excel
.
private function check_stuff($path) {
Excel::filter('chunk')->load($path)->chunk(250, function($results) {
// check something
return false;
});
return true;
}
Upvotes: 1
Views: 33
Reputation: 41903
Try to import it in the anonymous function:
private function check_stuff($path) {
$result = true;
Excel::filter('chunk')->load($path)->chunk(250, function($results) use (&$result) {
// check something
$result = false;
});
return $result;
}
Upvotes: 2
Reputation: 610
Have you tried this?
private function check_stuff($path) {
return Excel::filter('chunk')->load($path)->chunk(250, function($results) {
// check something
return false;
});
}
Upvotes: 0