David
David

Reputation: 4767

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.

Upvotes: 5

Views: 128

Answers (1)

tom
tom

Reputation: 19153

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

Upvotes: 2

Related Questions