且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP foreach 循环中的数组是如何读取的?

更新时间:2022-04-18 22:09:35

foreach()使用迭代器实现 - 因此它只调用一次返回数组的函数,然后使用指向现有结果集的迭代器继续每个项目.

foreach() is implemented using iterators - thus it only calls the function that returns an array once, and then uses the iterator which points to the existing result set to continue with each item.