[PHP-NOTES] note 130248 added to generator.send

[email protected] ("[email protected]")
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.