PHP: how can I sort and filter an “array”, that is an Object, implementing ArrayAccess?
问题 I have an object that is a collection of objects, behaving like an array. It's a database result object. Something like the following: $users = User::get(); foreach ($users as $user) echo $user->name . "\n"; The $users variable is an object that implements ArrayAccess and Countable interfaces. I'd like to sort and filter this "array", but I can't use array functions on it: $users = User::get(); $users = array_filter($users, function($user) {return $user->source == "Twitter";}); => Warning: