php reading files and moving down lines

Associate
Joined
19 Jul 2006
Posts
1,847
oh i can get php to read from a text file.
what i want to do now is put the first line into a variable then the second line in to a second variable. check something then make the first variable the same as the 3rd line
Psedo code
Variable 1 = first line
Variable 2 = second line
"do something"
clear variable 1 and 2
Variable 1 = third line
varible 2 = forth line
ect repeat till end of file.
 
that works a treat, is there a way of instead of putting
$line3
$line4 ect for each one of the lines.
as i dont know how many lines there will be
getting it to automatically create the smae amount of line variables as there is lines in the text.
 
cheers rob that works for the
$lines[$i]
but if i try to
PHP:
echo "$lines[$i + 1]";
i get
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in C:\xampplite\htdocs\passwordsite\read.php on line 14
i tried getting rid of the spaces or putting in [$i+[1]] and other variations but still get same result
 
Back
Top Bottom