I’m using shuffle() to randomly generate items on my site like so:
shuffle($items);
$shirts = array();
foreach ($items as $key => &$row) {
$shirts[$row['Id']] = $row['shirts'];
}
The code goes further, but basically it’s running a foreach and displays 12 results. However, shuffle() seems to only return the first 12 items in the array and shuffle them. The array may contain dozens of items, and I want to shuffle through the entire array. What am I doing wrong?
We need to see more code. As of right now according to the code, it should display every result (not just 12). This must mean that you’re cutting the array down to 12 before you even shuffle it.