3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* function has_next($array) { return next($array) === false && key($array) === null ? false : true; } */ $array1 = [ "one" => 1, "two" => 2, "three" => 3, "four" => 4 ]; while (current($array1)!==false) { $current = current($array1); $key = key($array1); echo "$key => $current\n"; if ($current < 2) { $array1[$key] = ++$current; } else { next($array1); } }

preferences:
63.82 ms | 402 KiB | 5 Q