$array = [
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
];
foreach ($array as $key => &$value) {
unset($array[$key]);
$array[] = $value;// the same situation with $array[$key] = $value;
}
If array elements are light there is possible to get 'Process exited with code 137.'
But if are higher than stdClass it kill all application.
Using foreach without using $key: `foreach ($array as &$value)`
generates: `Fatal error: Allowed memory size of...` - IMO this is better message for debugging what is wrong
Better message to be able to debug it, or possibility to use above construction :]