3v4l.org

run code in 300+ PHP versions simultaneously
<?php function random_index(array $source) { $max = count($source) - 1; $r = random_int(0, $max); $k = array_keys($source); return $k[$r]; } $array = [ 'apple' => 1234, 'boy' => 2345, 'cat' => 3456, 'dog' => 4567, 'echo' => 5678, 'fortune' => 6789 ]; $i = random_index($array); var_dump([$i, $array[$i]]);
Output for git.master_jit
array(2) { [0]=> string(3) "boy" [1]=> int(2345) }
Output for git.master
array(2) { [0]=> string(4) "echo" [1]=> int(5678) }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.28 ms | 401 KiB | 7 Q