note 128309 added to class.generator
| From: | chinassx at 126 dot com | Date: | Tue, 14 Mar 2023 14:24:38 +0000 |
| Subject: | note 128309 added to class.generator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220266@lists.php.net to get a copy of this message | ||
<?php
function fib($n)
{
$cur = 1;
$prev = 0;
$arr = array();
for ($i = 0; $i < $n; $i++) {
// yield $cur;
$temp = $cur;
$cur = $prev + $cur;
$prev = $temp;
array_push($arr,$cur);//åæ
}
array_unshift($arr,0,1);
return $arr;
}
$fibs = fib(9);
foreach ($fibs as $fib) {
echo " " . $fib;
}
// prints: 0 1 1 2 3 5 8 13 21 34 55
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 61.49.76.140)
----
Manual Page -- https://php.net/manual/en/class.generator.php
Edit -- https://main.php.net/note/edit/128309
Del: integrated -- https://main.php.net/note/delete/128309/integrated
Del: useless -- https://main.php.net/note/delete/128309/useless
Del: bad code -- https://main.php.net/note/delete/128309/bad+code
Del: spam -- https://main.php.net/note/delete/128309/spam
Del: non-english -- https://main.php.net/note/delete/128309/non-english
Del: in docs -- https://main.php.net/note/delete/128309/in+docs
Del: other reasons-- https://main.php.net/note/delete/128309
Reject -- https://main.php.net/note/reject/128309
Search -- https://main.php.net/manage/user-notes.php