I've been searching for this for a while but none of the solutions I've found match what I'm looking for.
Say I have an array of names:
$names = array('zack', 'tom', 'brad', 'tim');
I'd like to randomise those names but none can end up in the same position as it started in.
the shuffle() function doesn't seem do this.
I have tried the following which is probably not the best way to do it but for some reason this didn't work?:
$names = array('zack', 'tom', 'brad', 'tim');
$names2 = array('zack', 'tom', 'brad', 'tim');
do {
shuffle($names2);
} while($names === $names2);
I also need to keep the original array in the original order so shuffling the array and then shifting by one isn't an option.
How do i achieve a shuffle with no value remaining in it's original position?