jacobemerick / shuffle_slightly
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jacobemerick/shuffle_slightly
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2025-10-07 12:20:14 UTC
README
Function to slightly shuffle an array based on a tolerance parameter.
There may come a time when you want to shuffle an array but you don't want to completely ignore the order. This function, which behaves much like the native shuffle, will perform a slight shuffle.
For example, if you want to shuffle a simple array but you don't want to move any elements more than 2 positions away from their start, just do this.
$array = ['a', 'b', 'c', 'd', 'e']; jacobemerick\shuffle_slightly($array, 2);
Installation
Through composer:
$ composer require jacobemerick/shuffle_slightly:~1.0
More Information
I wrote a blog post talking about the reasoning, build, and some extra information about shuffling algorithms.