3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('TEST_VALUE_COUNT', 10); srand(15); $values = array(); for ($i = 0; $i < TEST_VALUE_COUNT; $i++) { $values[] = rand(); } srand(15); foreach($values as $key => $value) { if ($value !== rand()) { print "Bad value at " . $key; exit; } } echo "All were the same in " . count($values) . " values"; srand(15); shuffle($values); var_dump($values); $valuesShuffled = array() + $values; srand(15); shuffle($values); var_dump($valuesShuffled); var_dump($values); if (count(array_diff_assoc($values, $valuesShuffled)) == 0) { echo "Array was the same after a seeded shuffle"; } else { echo "Array was not the same after a seeded shuffle\n"; }
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.13, 7.3.0 - 7.3.1
All were the same in 10 valuesarray(10) { [0]=> int(591418979) [1]=> int(1989950309) [2]=> int(1747150714) [3]=> int(1822822116) [4]=> int(776397902) [5]=> int(238341312) [6]=> int(1757955405) [7]=> int(116744123) [8]=> int(1269925186) [9]=> int(384176070) } array(10) { [0]=> int(591418979) [1]=> int(1989950309) [2]=> int(1747150714) [3]=> int(1822822116) [4]=> int(776397902) [5]=> int(238341312) [6]=> int(1757955405) [7]=> int(116744123) [8]=> int(1269925186) [9]=> int(384176070) } array(10) { [0]=> int(1269925186) [1]=> int(384176070) [2]=> int(1989950309) [3]=> int(591418979) [4]=> int(1757955405) [5]=> int(238341312) [6]=> int(116744123) [7]=> int(776397902) [8]=> int(1822822116) [9]=> int(1747150714) } Array was not the same after a seeded shuffle
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
All were the same in 10 valuesarray(10) { [0]=> int(1106721597) [1]=> int(762299093) [2]=> int(843757392) [3]=> int(102227743) [4]=> int(504266128) [5]=> int(1681973265) [6]=> int(1445576550) [7]=> int(2111222096) [8]=> int(828439474) [9]=> int(594610055) } array(10) { [0]=> int(1106721597) [1]=> int(762299093) [2]=> int(843757392) [3]=> int(102227743) [4]=> int(504266128) [5]=> int(1681973265) [6]=> int(1445576550) [7]=> int(2111222096) [8]=> int(828439474) [9]=> int(594610055) } array(10) { [0]=> int(843757392) [1]=> int(1106721597) [2]=> int(2111222096) [3]=> int(828439474) [4]=> int(594610055) [5]=> int(1681973265) [6]=> int(762299093) [7]=> int(504266128) [8]=> int(1445576550) [9]=> int(102227743) } Array was not the same after a seeded shuffle

preferences:
158.77 ms | 405 KiB | 232 Q