php - 同一个生成器上的多个循环 - PHP
问题描述
我需要在多个循环上循环同一个生成器 - 我尝试使用倒带,但出现此错误 - “无法倒带已经运行的生成器”。
$gen = myGenerator();
while ($gen->valid()){
$document = $gen->current();
$gen->next();
//...
}
$gen->rewind(); //this is where i get the error
while ($gen->valid()){
$document = $gen->current();
$gen->next();
//...
}
解决方案
推荐阅读
- amazon-web-services - cloudformation 多重 if 条件
- python - 如何使用存档获取网页的所有损坏链接?
- android - 无法在自定义 Rom [Android 11 (Rooted-Magisk)] 上执行颤振运行和 adb 安装/卸载
- firebase-cloud-messaging - 生成代码以获取 fcm 推送通知的刷新令牌的范围应该是什么?
- javascript - 如何自动归档输入框并单击搜索按钮?
- json - 获取返回对象类型的 JSON Schema
- java - Qt从java Activity调用c++方法
- .net - .NET 迁移默认为主数据库
- sql - SQL - FROM(子查询)和 WHERE - IN(子查询)之间的区别
- python - 有没有办法使用 pyopenssl 或密码学或任何其他库检查 CRL 编号和颁发者名称哈希?