且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从foreach循环内的数组中删除对象?

更新时间:2023-11-30 23:37:58

foreach($array as $elementKey => $element) {
    foreach($element as $valueKey => $value) {
        if($valueKey == 'id' && $value == 'searched_value'){
            //delete this particular object from the $array
            unset($array[$elementKey]);
        } 
    }
}