Unset an array element inside a foreach loop
Posted
by Summer
on Stack Overflow
See other posts from Stack Overflow
or by Summer
Published on 2010-06-16T15:44:50Z
Indexed on
2010/06/16
15:52 UTC
Read the original article
Hit count: 144
php
I'm accessing an array by reference inside a foreach loop, but the unset() function doesn't seem to be working:
foreach ( $this->result['list'] as &$row ) {
if ($this_row_is_boring) {
unset($row);
}
}
print_r($this->result['list']); // Includes rows I thought I unset
Ideas? Thanks!
© Stack Overflow or respective owner