- str_repeat: documentation ( source)
<?php
class A1 {
var $s;
protected function a () {
$i =0 ;
while (true) {
$i++;
if ($i > 10000) { break; }
foreach ([['a' => 1],2, ['a' => 2]] as $p) {
if ($p == 2) {
continue;
}
if ($i %100 == 0) {
$this->s .= str_repeat('0123456789', 1000000);
}
yield $p['a'] => 123;
}
}
}
public function b(){
$sum = 0;
foreach ( $this->a() as $k => $v ) {
$sum += $k + $v;
}
echo 'Done: ', $sum;
}}
(new A1)->b();