gpt4 book ai didi

php - 为什么迭代以无限循环结束的 ArrayIterator?

转载 作者:可可西里 更新时间:2023-10-31 23:58:53 26 4
gpt4 key购买 nike

我代码中的数组很大,所以我将它粘贴到 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com