For LINQ in PHP, I used https://github.com/Athari/YaLinqo
I don't know how to pass a variable in where
clause.
public function filter($arr, $find) {
Enumerable::from($arr)->where(function($val) { return stripos($val->item, $find) > -1; })->toArray();
}
Seems is not working like $find
is not defined but I send it as method's parameter.
You could use use
statement:
Enumerable::from($arr)
->where(function($val) use ($find) {
return stripos($val->item, $find) > -1;
})
->toArray();