Possible Duplicate:
Output array elements randomly with PHP
Lets say we have this code:
<? if (isset($specialoffers)) { ?>
<? foreach ($specialoffers as $value) { ?>
<div>product #</div>
<?};?>
<?};?>
For example this list may be different everytime, it may have 1 product, and it may have 58 products. I want do display only 10 products in the list and in a random order.
How to do that?
I would like not to touch the SQL query!
Take a look at the array_rand function which takes one or more random elements from an array.
So, you could do something along the lines of: