Show X amount of random links w/o duplicates.

SpaceshipSpaceship
Watch

Daniel

Danltn.comVIP Member
Impact
133
Hi there, this PHP script/snippet will show X amount of random links your site.

PHP:
 <?php

/*
 * Script written by Danltn
 * Leave this message intact for use, visitors won't see it, don't worry
 * URL: http://danltn.com
 */

function site($site, $url) 
  {
  // This function turns the provided parameters into a link.
    $link = '<a href="'. $url . '">' . $site . '</a>';
    return $link; 
  } 
 // Set your websites here, remember to increase the number by one each time.

$website[1] = site("Google","http://google.com");
$website[2] = site("MSN","http://msn.com");
$website[3] = site("Yahoo","http://yahoo.com");
$website[4] = site("Ask","http://ask.com");
$website[5] = site("Ebay","http://ebay.com");

$before = ""; // What should go before each link, you could for example use it as a <li> element. I've set it to nothing.
$after = "<br />"; // What should go after, it could be </li> or <br /> for example. I've set it to line break.

$show = 3; // Set the amount of websites to list here

// PHP Magic
$show = floor($show);
if ($show != 1) {
if ($show > count($website)) { $show = count($website); }
$r = array_rand($website, $show);
for ($k=0; $k < $show; $k++)
{
echo $before . $website[$r[$k]] . $after;
} } elseif ($show = 1) { $rand = rand(1, count($website)); echo $website[$rand]; }


?>

http://paste.biz/paste-2752.html

Enjoy. :tu:
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
Dynadot — .com TransferDynadot — .com Transfer

We're social

Spaceship
Domain Recover
CatchDoms
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back