3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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); $valuesShuffled = array_merge(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
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(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 - 7.0.14
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(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