I am using this to randomize the rows of a repeater field. This technique worked a while back on another site a long time ago. However on this site I am getting the output, just not randomized. Any help is greatly appreciated.
$repeater = get_field('contributors_grid','option');
// try echoing it to see it it's an array
There are times when this might return an array, but there are other times when it will just return the number of rows in the repeater. It is unclear to me why there is inconsistent behavior like this when getting a repeater.
You may need to loop through the repeater to get the values before you can randomize them.
I’ve actually never used array_rand before so I did some testing. Basically what I found was that no matter how many items you want returned, the keys are always returned in order. So it you pick 3 of 5 you might get 0, 2, 4 but never 4, 0, 2. So when selecting the 5 of 5 it will always return 0, 1, 2, 3, 4