i have an array and its data are displayed in a grid using a foreach loop. the index of the foreach is used as part of url for each entry in the grid.
$i=0;
foreach ($array as $grid) {
$name = $grid->name;
$address = $grid->address;
echo '<li> <a href="javascript:myclick('.$i.');" title="">' . $name . '</a> </li>';
$i++;
}
i'd like to display the array in random order so i used shuffle(); but the index gets destroyed and the links break. i have been looking around for 2 days and tried many different kinds of functions that were supposed to keep the index untouched but with no luck. any help would be much appreciated.
safer shuffle the real keys of an array