PX : code

Random Link by Sascha Blansjaar
Download this code


<?
// array with link entries in the form url|description
$linkarray = array("http://php.net/|PHP Official Site and Distribution",
"http://www.devshed.com/|DevShed - Open Source Resources",
"http://www.e-gineer.com/phpkb/index.phtml|e-gineer - PHP Knowledge Base",
"http://phpclasses.upperdesign.com/|PHP Classes Repository",
"http://www.phpbuilder.com/|PHPBuilder.com - PHP Resources",
"http://phtml.com/|phtml.com - Free PHP Scripts",
"http://www.phpwizard.net/|phpWizard.net - PHP Resources",
"http://px.sklar.com/|PX: PHP Code Exchange",
"http://www.weberdev.com/|Berber's Web Development Pages"); 

// seed the random number generator
srand((double)microtime()*1000000);
// get a random entry
$randval = rand(0,count($linkarray)-1); 

// explode random entry into an array
$entry = explode("|",$linkarray[$randval]);
// print entry
print ("Visit: <a href=\"$entry[0]\" target=\"_blank\">$entry[1]</a>");

?>

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.