Jump to content

Generate Random Links from BIG LIST of links ??


luke777

Recommended Posts

I need some kind of code in php that can display 10 random links from a big list of links.

 

So i have a file links.php which contains a list of lets say 1000's of links,

how can i grab just 10 RANDOM links from that list to display on a webpage.

 

Please help me !

 

Thanks Luke.

Would have been a nice idea to have had the links in a database. Then this would have been trivial.

 

Does links.php contain anything except thousands of lines each one of which is a link?  What's its structure?  Post a few lines of it.

Dang while loops!

 

I think you should use this instead... They do the exact same thing though.. lol

<?php
$lines = file("./link_list.txt");
shuffle($lines);
for($i = 0; $i < 10; $i++)
{
        echo "<a href=\"$lines[$i]\">$lines[$i]</a>";
}
?>

 

 

Also, I believe the only way to get duplicates, is if you have duplicates in the file....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.