Is it ok to unset elements in an array that is being iterated with foreach? e.g.
- Code: Select all
$x = 0;
foreach($arData as $key => $value) {
if( $key == "my_key_$x" ) {
unset($arData["my_key_$x"]);
}
$x++;
}
I'm iterating through an array, looking for certain keys, then when they are found, i remove them and continue iterating.
Just wondered if this is ok?

