对于 PHP 中的 LINQ,我使用了 https://github.com/Athari/YaLinqo
我不知道如何在 where
子句中传递变量。
public function filter($arr, $find) {
Enumerable::from($arr)->where(function($val) { return stripos($val->item, $find) > -1; })->toArray();
}
似乎没有像 $find
未定义一样工作,但我将它作为方法的参数发送。
最佳答案
您可以使用 use
语句:
Enumerable::from($arr)
->where(function($val) use ($find) {
return stripos($val->item, $find) > -1;
})
->toArray();
关于php - 在 where 子句中发送一个变量 LINQ PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48005242/