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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.