3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('MAX_INT', 100); // fill array by unique values // @param int $n array size // @return array with randow unique values function uniqRand($n) { $ret = []; for($i = 0; $i < $n; $i++) { $unq = false; while($unq != true) { $v = rand(0, MAX_INT); if(!count($ret) || !in_array($v, $ret)) { $ret[$i] = $v; $unq = true; } } } return $ret; } // uniqRand(n int) int[] // uniqRand(5) -> [1,5,100,2,4] $ret = uniqRand(5); var_dump($ret);
Output for 8.0.9
array(5) { [0]=> int(64) [1]=> int(97) [2]=> int(10) [3]=> int(81) [4]=> int(13) }
Output for 8.0.8
array(5) { [0]=> int(83) [1]=> int(29) [2]=> int(53) [3]=> int(18) [4]=> int(25) }
Output for 8.0.7
array(5) { [0]=> int(92) [1]=> int(28) [2]=> int(65) [3]=> int(39) [4]=> int(33) }
Output for 8.0.6
array(5) { [0]=> int(23) [1]=> int(34) [2]=> int(78) [3]=> int(87) [4]=> int(52) }
Output for 8.0.5
array(5) { [0]=> int(23) [1]=> int(48) [2]=> int(50) [3]=> int(31) [4]=> int(18) }
Output for 8.0.3
array(5) { [0]=> int(75) [1]=> int(89) [2]=> int(27) [3]=> int(32) [4]=> int(62) }
Output for 8.0.2
array(5) { [0]=> int(47) [1]=> int(62) [2]=> int(74) [3]=> int(0) [4]=> int(67) }
Output for 8.0.1
array(5) { [0]=> int(16) [1]=> int(60) [2]=> int(98) [3]=> int(52) [4]=> int(70) }
Output for 8.0.0
array(5) { [0]=> int(96) [1]=> int(83) [2]=> int(36) [3]=> int(43) [4]=> int(58) }
Output for 7.4.22
array(5) { [0]=> int(91) [1]=> int(17) [2]=> int(62) [3]=> int(42) [4]=> int(50) }
Output for 7.4.21
array(5) { [0]=> int(70) [1]=> int(35) [2]=> int(47) [3]=> int(95) [4]=> int(31) }
Output for 7.4.20
array(5) { [0]=> int(51) [1]=> int(49) [2]=> int(17) [3]=> int(41) [4]=> int(68) }
Output for 7.4.19
array(5) { [0]=> int(10) [1]=> int(25) [2]=> int(58) [3]=> int(19) [4]=> int(37) }
Output for 7.4.18
array(5) { [0]=> int(39) [1]=> int(19) [2]=> int(57) [3]=> int(87) [4]=> int(11) }
Output for 7.4.16
array(5) { [0]=> int(24) [1]=> int(52) [2]=> int(62) [3]=> int(44) [4]=> int(100) }
Output for 7.4.15
array(5) { [0]=> int(58) [1]=> int(3) [2]=> int(91) [3]=> int(87) [4]=> int(94) }
Output for 7.4.14
array(5) { [0]=> int(4) [1]=> int(81) [2]=> int(64) [3]=> int(50) [4]=> int(61) }
Output for 7.4.13
array(5) { [0]=> int(5) [1]=> int(9) [2]=> int(15) [3]=> int(81) [4]=> int(100) }
Output for 7.4.12
array(5) { [0]=> int(68) [1]=> int(5) [2]=> int(82) [3]=> int(12) [4]=> int(25) }
Output for 7.4.11
array(5) { [0]=> int(71) [1]=> int(64) [2]=> int(51) [3]=> int(73) [4]=> int(63) }
Output for 7.4.10
array(5) { [0]=> int(25) [1]=> int(65) [2]=> int(71) [3]=> int(35) [4]=> int(100) }
Output for 7.4.9
array(5) { [0]=> int(32) [1]=> int(93) [2]=> int(54) [3]=> int(76) [4]=> int(58) }
Output for 7.4.8
array(5) { [0]=> int(59) [1]=> int(18) [2]=> int(57) [3]=> int(96) [4]=> int(19) }
Output for 7.3.22, 7.4.7
array(5) { [0]=> int(31) [1]=> int(86) [2]=> int(23) [3]=> int(36) [4]=> int(35) }
Output for 7.4.6
array(5) { [0]=> int(93) [1]=> int(68) [2]=> int(4) [3]=> int(100) [4]=> int(85) }
Output for 7.4.5
array(5) { [0]=> int(20) [1]=> int(43) [2]=> int(60) [3]=> int(65) [4]=> int(54) }
Output for 7.4.4
array(5) { [0]=> int(25) [1]=> int(15) [2]=> int(26) [3]=> int(16) [4]=> int(97) }
Output for 7.4.3
array(5) { [0]=> int(65) [1]=> int(13) [2]=> int(54) [3]=> int(33) [4]=> int(95) }
Output for 7.4.2
array(5) { [0]=> int(30) [1]=> int(87) [2]=> int(62) [3]=> int(100) [4]=> int(39) }
Output for 7.4.1
array(5) { [0]=> int(0) [1]=> int(89) [2]=> int(90) [3]=> int(52) [4]=> int(54) }
Output for 7.4.0
array(5) { [0]=> int(81) [1]=> int(94) [2]=> int(47) [3]=> int(79) [4]=> int(44) }
Output for 7.3.29
array(5) { [0]=> int(48) [1]=> int(65) [2]=> int(7) [3]=> int(85) [4]=> int(29) }
Output for 7.3.28
array(5) { [0]=> int(73) [1]=> int(66) [2]=> int(71) [3]=> int(25) [4]=> int(39) }
Output for 7.3.27
array(5) { [0]=> int(85) [1]=> int(90) [2]=> int(13) [3]=> int(88) [4]=> int(84) }
Output for 7.3.26
array(5) { [0]=> int(43) [1]=> int(7) [2]=> int(95) [3]=> int(93) [4]=> int(63) }
Output for 7.3.25
array(5) { [0]=> int(54) [1]=> int(26) [2]=> int(47) [3]=> int(41) [4]=> int(28) }
Output for 7.3.24
array(5) { [0]=> int(95) [1]=> int(34) [2]=> int(83) [3]=> int(74) [4]=> int(49) }
Output for 7.3.23
array(5) { [0]=> int(81) [1]=> int(71) [2]=> int(38) [3]=> int(1) [4]=> int(0) }
Output for 7.3.21
array(5) { [0]=> int(2) [1]=> int(87) [2]=> int(18) [3]=> int(39) [4]=> int(62) }
Output for 7.3.20
array(5) { [0]=> int(91) [1]=> int(11) [2]=> int(70) [3]=> int(54) [4]=> int(57) }
Output for 7.3.19
array(5) { [0]=> int(20) [1]=> int(82) [2]=> int(61) [3]=> int(14) [4]=> int(96) }
Output for 7.3.18
array(5) { [0]=> int(100) [1]=> int(35) [2]=> int(73) [3]=> int(65) [4]=> int(94) }
Output for 7.3.17
array(5) { [0]=> int(99) [1]=> int(93) [2]=> int(9) [3]=> int(18) [4]=> int(75) }
Output for 7.3.16
array(5) { [0]=> int(79) [1]=> int(61) [2]=> int(2) [3]=> int(6) [4]=> int(38) }
Output for 7.3.15
array(5) { [0]=> int(85) [1]=> int(87) [2]=> int(78) [3]=> int(21) [4]=> int(57) }
Output for 7.3.14
array(5) { [0]=> int(6) [1]=> int(43) [2]=> int(25) [3]=> int(10) [4]=> int(16) }
Output for 7.3.13
array(5) { [0]=> int(97) [1]=> int(96) [2]=> int(87) [3]=> int(41) [4]=> int(70) }
Output for 7.3.12
array(5) { [0]=> int(12) [1]=> int(27) [2]=> int(0) [3]=> int(52) [4]=> int(66) }
Output for 7.3.11
array(5) { [0]=> int(87) [1]=> int(69) [2]=> int(52) [3]=> int(73) [4]=> int(98) }
Output for 7.3.10
array(5) { [0]=> int(68) [1]=> int(67) [2]=> int(98) [3]=> int(83) [4]=> int(60) }
Output for 7.3.9
array(5) { [0]=> int(17) [1]=> int(5) [2]=> int(62) [3]=> int(59) [4]=> int(95) }
Output for 7.3.8
array(5) { [0]=> int(38) [1]=> int(41) [2]=> int(84) [3]=> int(3) [4]=> int(100) }
Output for 7.3.7
array(5) { [0]=> int(99) [1]=> int(78) [2]=> int(88) [3]=> int(52) [4]=> int(85) }
Output for 7.3.6
array(5) { [0]=> int(32) [1]=> int(16) [2]=> int(35) [3]=> int(55) [4]=> int(60) }
Output for 7.3.5
array(5) { [0]=> int(84) [1]=> int(82) [2]=> int(34) [3]=> int(6) [4]=> int(60) }
Output for 7.3.4
array(5) { [0]=> int(91) [1]=> int(93) [2]=> int(83) [3]=> int(85) [4]=> int(66) }
Output for 7.3.3
array(5) { [0]=> int(7) [1]=> int(36) [2]=> int(69) [3]=> int(50) [4]=> int(74) }
Output for 7.3.2
array(5) { [0]=> int(78) [1]=> int(4) [2]=> int(50) [3]=> int(57) [4]=> int(82) }
Output for 7.3.1
array(5) { [0]=> int(87) [1]=> int(12) [2]=> int(19) [3]=> int(13) [4]=> int(55) }
Output for 7.3.0
array(5) { [0]=> int(93) [1]=> int(83) [2]=> int(96) [3]=> int(51) [4]=> int(44) }

preferences:
62.45 ms | 493 KiB | 5 Q