Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a defined random order for an array in PHP

I have an array of over 1000s keys in PHP which I want to randomize. I am currently using shuffle to do this, however I want the shuffled order to be the same everytime. So, random but always in the same random order everytime the script is ran.

It's a client request :). Randomize, but keep it the same random order everytime.

like image 458
David Avatar asked Nov 03 '22 08:11

David


1 Answers

Call srand(int seed) first, with a constant. e.g. srand(123).

like image 134
tom Avatar answered Nov 15 '22 09:11

tom