【发布时间】:2013-12-02 19:57:58
【问题描述】:
因为这似乎是我必须做的才能获得这种效果:
$arr = ['a'=>'first', 'b'=>'second', ...];
$iter = new ArrayIterator( $arr );
// Do a bunch of iterations...
$iter->next();
// ...
$new_iter = new ArrayIterator( $arr );
while( $new_iter->key() != $iter->key() ) {
$new_iter->next();
}
编辑:另外,为了清楚起见,我不应该用unset() 修改基本数组吗?我认为数组迭代器存储自己的基本数组副本,因此使用offsetUnset() 似乎不正确。
【问题讨论】: