Cod*_*ium 3 php infinite-loop arrayiterator
我的代码中的数组非常大,所以我将它粘贴在pastebin中.http://pastebin.com/6tviT2Xj
我不明白为什么我会得到无限循环
这个脚本的逻辑是:
$it = new ArrayIterator($options);
while($it->valid()) {
print $it->key();
print $it->current();
}
Run Code Online (Sandbox Code Playgroud)
因为你永远不会移动你的迭代器(使用ArrayIterator :: next()).
while ($it->valid()) {
...
$it->next();
}
Run Code Online (Sandbox Code Playgroud)