3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* * yield expression: what is evaluated first: key or value? */ function genkey($key) { echo "(key) $key\n"; return $key; } function value($value) { echo "(value) $value\n"; return $value; } $gen = function() { foreach(range(0, 2) as $i) { yield genkey(chr(65+$i)) => value($i); } }; iterator_to_array($gen());
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
(key) A (value) 0 (key) B (value) 1 (key) C (value) 2