我代码中的数组很大,所以我将它粘贴到 pastebin 中。 http://pastebin.com/6tviT2Xj
我不明白为什么我会死循环
这个脚本的逻辑是:
$it = new ArrayIterator($options);
while($it->valid()) {
print $it->key();
print $it->current();
}
最佳答案
因为您永远不会在迭代器 ( with ArrayIterator::next() ) 中移动。
while ($it->valid()) {
...
$it->next();
}
关于php - 为什么迭代以无限循环结束的 ArrayIterator?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12709548/