Forum Moderators: coopster
<?php
// Necessary Variables:
$RANDOM_TXT_FILE = "sample_data.txt";
// End Necessary Variables section
srand((double)microtime()*1000000);
if (file_exists($RANDOM_TXT_FILE)) {
$arry_txt = preg_split("/--NEXT--/", join('', file($RANDOM_TXT_FILE)));
echo $arry_txt[rand(0, sizeof($arry_txt) -1)];
} else {
echo "Error: can't open $RANDOM_IMG_FILE file";
}
?>
1:Line 1<BR>
1:Line 2<BR>
1:Line 3<BR>
--NEXT--
2:Line 1<BR>
2:Line 2<BR>
2:Line 3<BR>
--NEXT--
3:Line 1<BR>
3:Line 2<BR>
3:Line 3<BR>
--NEXT--
4:Line 1<BR>
4:Line 2<BR>
4:Line 3<BR>
--NEXT--
5:Line 1<BR>
5:Line 2<BR>
5:Line 3<BR>
--NEXT--
6:Line 1<BR>
6:Line 2<BR>
6:Line 3<BR>
so if i can make this work so it grabs random links on a daily basics from a text file.....i will be happy and never have a worry in my mind ever....lol
Thanks
Eric
<?php
$textfile ="random.txt"; // change to the filename/path of your file
$items = file("$textfile");
$item = rand(0, sizeof($items)-1);
echo $items[$item];
?>
You would need to include the href tag in the text file, or enclose the above code in href tags for the text to be a link. The random.txt file should be your links on a separate line for each.