3v4l.org

run code in 300+ PHP versions simultaneously
<?php exit(); $countMap = (function(){ yield "a" => 5; yield "b" => 2; yield "c" => 3; })(); // emits "C" times the element "K" from the given Iterator<K, C> $iterator = new MultiplyIterator($countMap); // better name for this? $iterator->rewind(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "b"); $iterator->next(); assert($iterator->current() === "b"); $iterator->next(); assert($iterator->current() === "c"); $iterator->next(); assert($iterator->current() === "c"); $iterator->next(); assert($iterator->current() === "c"); $iterator->next();

preferences:
31.58 ms | 404 KiB | 5 Q