Page 1 of 1

Random links Question

Posted: Wed Jun 11, 2003 7:23 am
by ampersand
How can I make random links from a text document ? so I just need to add links to this txt file and they appear random on a website.

Thanks in advance
Blackhat

Posted: Wed Jun 11, 2003 7:29 am
by []InTeR[]

Code: Select all

$links = file("links.txt");
echo $links[rand(0,sizeof($links)-1)];

Posted: Wed Jun 11, 2003 7:29 am
by volka
if you have one link per line in that file
take a look at http://php.net/file and http://php.net/array_rand

edit: @Inter: readfile adds the contents to the output stream and returns the size.