1--TEST-- 2array_rand() is not affected by MT_RAND_PHP as with PHP < 8.2 3--FILE-- 4<?php 5 6$array = [ 7 'foo', 8 'bar', 9 'baz', 10]; 11 12mt_srand(1, MT_RAND_PHP); 13function custom_array_rand() { 14 global $array; 15 $key = array_rand($array); 16 var_dump('found key ' . $key); 17 return $array[$key]; 18} 19 20var_dump( 21 custom_array_rand(), 22 custom_array_rand(), 23 custom_array_rand(), 24); 25?> 26--EXPECTF-- 27string(11) "found key 0" 28string(11) "found key 1" 29string(11) "found key 0" 30string(3) "foo" 31string(3) "bar" 32string(3) "foo" 33