I hope I didn't misunderstand your question, but I wrote up something quick. It might not be so easy to understand, but I guess it's worth a try
PHP Code:
<?php // Each link will be stored in an array. // $links is an array of all the link arrays. $links = array( array('url'=>'http://www.google.com', 'label'=>'Google'), array('url'=>'http://www.digg.com', 'label'=>'Digg'), array('url'=>'http://www.yahoo.com', 'label'=>'Yahoo!'), array('url'=>'http://www.ask.com', 'label'=>'Ask'), array('url'=>'http://www.reddit.com', 'label'=>'Reddit') );
// This will pick out 3 keys from the $links array. A key is the position of a link array. $random_keys = array_rand($links, 3);
// Here we go through each of the keys, and print out the values from the $links array foreach ($random_keys as $key) { printf("<a href=\"%s\">%s</a><br />", $links[$key]['url'], $links[$key]['label']); } ?>
That script will print out 3 random links from the $links array.
if you want to find out what the functions I used actually do, you should look it up at php.net
like: www.php.net/array_rand
That's how I learned PHP. By tinkering with other peoples code and learning how all the functions they used works.
Hope it helps 
Last edited by TyR; 09-21-2008 at 01:03 PM..
Reason: made some mistakes
|