php – 在给定属性值的对象数组中查找数组键

我有一个像这样的对象数组:

Array
(
    [945] => member Object
        (
            [id] => 13317
            [name] => Test 999
            [last_name] => Test 999
        )

    [54] => member Object
        (
            [id] => 13316
            [name] => Manuel
            [last_name] => Maria parra
        )

    [654] => member Object
        (
            [id] => 13315
            [name] => Byron 
            [last_name] => Castillo
        )

    [656] => member Object
        (
            [id] => 13314
            [name] => Cesar
            [last_name] => Vasquez
        )
)

我需要根据属性值删除其中一个对象.
例如,我想从数组中删除对象id 13316.

这是功能方法:

$neededObjects = array_filter(
    $objects,
    function ($e) {
        return $e->id != 13316;
    }
);
http://stackoverflow.com/questions/4166198/find-array-key-in-objects-array-given-an-attribute-value

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:php – 在给定属性值的对象数组中查找数组键