Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

fool's question want your answer, please

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

fool's question want your answer, please

Postby mybird » Wed Oct 30, 2002 7:15 am

when i use fopen() to open my txt file and use fgets() to read it to string, it can only read one line of my txt file (my txt file include some 'return' marks); so i really want to know how to read all my text out???
mybird
New php-forum User
New php-forum User
 
Posts: 7
Joined: Sat Oct 12, 2002 1:09 am

Postby DoppyNL » Wed Oct 30, 2002 7:48 am

from the manualpage of fgets:
php website wrote:Returns a string of up to length - 1 bytes read from the file pointed to by fp. Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, the length defaults to 1k, or 1024 bytes.


fgets will stop reading when the end of the line is reached.
simply use fgets again and it will read the next line.

Greetz Daan
DoppyNL
 

Postby mybird » Wed Oct 30, 2002 8:20 am

really? won't it read the same content? let me have a try
thanks a lot
mybird
New php-forum User
New php-forum User
 
Posts: 7
Joined: Sat Oct 12, 2002 1:09 am

Postby DoppyNL » Wed Oct 30, 2002 8:21 am

The File pointer wil have moved after the first time you've read from the file, so .. nope.

Greetz Daan
DoppyNL
 


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.