I have an array of 15 or so items.
I want to randomly select 10 of those out of the array and process them with a foreach loop.
The application is sort of a "Site Highlights" where a random 10 items are featured on a page. I can add to the array of 15 items at any time, but the result of my randomizer should select only 10 items, at random, without duplication.
This way, each time a user visits the page, a random selection of 10 items is displayed.
How?
I have some randomizer code already for selecting 1 (one) item at random from an array... i need to expand on this.
here is my "Randomizer" code...
<?php
//Define your themes
$themeselector = array("theme1", "theme2", "theme3", "theme4");
//Use rand to select a random array index.
$themeselect = $themeselector[rand(0,count($themeselector)-1)];
//Just echoing it to test to make sure it works. Use it however you need from here.
echo $themeselect;
?>
The only difference in this implementation is that the array will be a nested one... something like this....
$mystuff = array (
array ("Item1"=>"URL 1", "Name"=>"Bobs Place", "Description"=>"All Of Bob"),
array ("Lunch"=>"Pizza", "Dinner"=>"Soup", "Smoking"=>"no")
);
Ideas???