note 130248 added to generator.send

From: Date: Tue, 15 Apr 2025 15:09:42 +0000
Subject: note 130248 added to generator.send
Groups: php.notes 
Request: Send a blank email to php-notes+get-222087@lists.php.net to get a copy of this message
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

« previous php.notes (#222087) next »