3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate_result_array($where) { return array_fill(0, count($where), 0); } function generator($where) { for (;;) { yield rand(0, count($where) - 1); if (42 === rand(0, 100000)) { break; } } }; function main() { $where = [ 'Péché mignon', 'McDo', 'Flunch' ]; $results = generate_result_array($where); srand(time()); foreach (generator($where) as $result) { $results[$result]++; } echo $where[array_search(max($results), $results)], "\n"; } main();

preferences:
33.94 ms | 402 KiB | 5 Q