mardi 2 février 2021

PHP Shuffle in PHP 7.1+ produces different results

I use the shuffle() function to emulate a letter bag in a word game.

I recently upgraded from PHP 5 to PHP 7, and have found that on the newer version, the shuffle function isn't quite as good for my purposes.

I used to start with the letters clumped and it would shuffle them nicely so there was a decent but unpredictable letter order. On 7.1+, it frequently produces clumps of the same letters, whereas getting those clumps was rare on 5.x

I saw that they changed the internal algorithm in 7.1.

Is there any way to emulate the older way shuffle worked in order to produce results more closely to how they were in PHP 5?




Aucun commentaire:

Enregistrer un commentaire