PX : code

Rand-O-Links by David Reid
Download this code


--randlinks.php--
<?php
    
/*
     *  Rand-O-Links                                  
     *  By: David Reid <dreid@dreid.org>      
     */

    /* User Configuration */
    
$rand_links_file "rand_links.txt";
    
$num_links "5";
    
$target "_top";

    
/* Program Code */

    
srand((double)microtime()*1000000); 
    
    
$link_array file($rand_links_file);

    function 
get_links($num_links$link_array) {
        
$i=0;
    
        while(
$i $num_links) {
            
$rand_val rand(0,count($link_array)-1);

            if(
$link_array[$rand_val] != "used") {            
                
$link explode"|",$link_array[$rand_val]);
                print(
"<A HREF=\"$link[0]\" TARGET=\"$target\">$link[1]</A><BR>\n");
                
$link_array[$rand_val] = "used";
                
$i++;
            }
        }
    }
        
    
get_links($num_links$link_array);
?>

--rand_links.txt--
http://www.phpbuilder.com/|PHP Builder
http://px.sklar.com/|PHP Code Exchange
http://www.devshed.com/|DevShed
http://www.php.net/|PHP.Net
http://www.ddj.com/|Dr. Dobbs Journal
http://www.webmonkey.com/|Webmonkey
http://www.zikri.com/books.html|Planet Books

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.