Category Archive: PHP Development

Oct 27

PHP Unset ArrayObject in foreach skip the following item – unexpected behaviour

When you unset the item from array in foreach, all works as expected $array = [1,2,3,4]; foreach($array as $key => $value) { if($value === 2) { unset($array[$key]); continue; } echo “$value “; } Will return following: 1 3 4 When you want to do the same with ArrayObject, you would expect exactly the same behaviour. …

Continue reading »