| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
I will allow myself to edit the code baohx2000 at gmail dot com. I suppose, it should be `$items[] = $item;` instead of `$items[] = yield;`:
<?php
function importer()
{
$max = 500;
$items = [];
while (true) {
$item = yield;
if ($item !== null) {
$items[] = $item;
}
if ($item === null || count($items) >= $max) {
// do batch operations
$items = [];
}
}
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 88.156.209.7)
----
Manual Page -- https://php.net/manual/en/generator.send.php
Edit -- https://main.php.net/note/edit/130248
Del: integrated -- https://main.php.net/note/delete/130248/integrated
Del: useless -- https://main.php.net/note/delete/130248/useless
Del: bad code -- https://main.php.net/note/delete/130248/bad+code
Del: spam -- https://main.php.net/note/delete/130248/spam
Del: non-english -- https://main.php.net/note/delete/130248/non-english
Del: in docs -- https://main.php.net/note/delete/130248/in+docs
Del: other reasons-- https://main.php.net/note/delete/130248
Reject -- https://main.php.net/note/reject/130248
Search -- https://main.php.net/manage/user-notes.php