while (isset($quote=file_diary[rand(0, count($file_diary)-1)]) && $i==0)
{
echo $quote;
$i++;
}
I just need a way to get a random line from one text file except blank lines...
My text is like this:
1
2
3
4
5
and so on...
Thanks!
Whats wrong with isset?
Moderator: General Moderators
well right off... if you have the && $i == 0 and you are incrementing $i++ at the end of your loop then it's only going to go through once...
try this... not sure if it'll work but...(this is only for printing them once you have them in an array...)
but that won't keep it from display multiple copies of the same entry...
you'll need to lookup some file functions to get the file into the array.
try this... not sure if it'll work but...(this is only for printing them once you have them in an array...)
Code: Select all
for ( $i = 0; $i < count($file_diary); $i++) {
echo($file_diaryїrand(0,count($file_diary)-1)]);
}you'll need to lookup some file functions to get the file into the array.