Re: How to get a certain line from a file

From: Date: Tue, 04 Feb 2003 18:00:39 +0000
Subject: Re: How to get a certain line from a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-134306@lists.php.net to get a copy of this message
On Tue, 4 Feb 2003, The New Source wrote: > How can I get a certain line from a file? > > If I get a file in this way: > > $f = > fopen("http://www.url.com/index.htm","r"); > > How can I get a certain line of the file index.htm? > > I would need to get the line number 232, or lines from 232 to 238. How > can I get this content? Either loop through it with fgets() or simply use file() and use the required array elements (lines). Most likely using fopen/fgets() will be more efficient as you won't need every line but file() is just so easy to use. Although really this problem doesn't sound very efficient to begin with, you may want to rethink the logic here or ask your content provider for a RSS version of the content or something... See: http://www.php.net/file http://www.php.net/fgets Regards, Philip

« previous php.general (#134306) next »