how using php can i read a specified line/lines of a text file. an example i would like to read lines 1-4 and output them to a page. another example would be read line 5 and output it to a page.
any ideas?
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
with fopen() and fgets() (or fread() if you develop cross-platform stuff). fgets read one line, so you can have a loop until the pointer is on the line you need.
do you have any code for this? as i'm a little bit confused as i'm new to php.
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
thanks raf your code explains it a lot better. I did read the manual section on it earlier and that was what left me a little confused.
thanks and happy easter.
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
duniyadnd thanks for that it could prove very useful later.
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
$line == 0;
$array = file($file_name);
//need a loop system while not end of file
$line++;
echo $array[$line];
if i use while or another method how can i detect the end of the file? so that htere are no more lines left to read?
which is the correct syntax to use as a loop with the condition that its not the end of the file? to go in the space of the cooment.
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
I will try it out, but wouldn't an error be produced if it looks for part of the array that doesn't exist? e.g. it looks for arrayline number nine in an eight lined text file.
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
No error, as it looks at the last element minus one. You're not looking at the file, you looking at the array, so you only concerned with the array length, which you got already, by using the sizeof function (personally, i use the count function, but they both get the job done).
it will prove very useful and it has solved my current problem.
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished