Skip to content
Advertisement

Shuffle() returns same results

I’m having a problem with using a basic shuffle() function in Laravel. It returns the same result, which seems to be changing once every 10 or 20 minutes.

Here’s the basic code I’m testing:

$ar = ['a', 'b', 'c'];
shuffle($ar);
var_dump($ar);
Log::info(json_encode($ar));

And here’s the log:

enter image description here

Advertisement

Answer

You probably initialize your random seed with a constant value somewhere else.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement