Re: Printing line "x" in a file
| From: | Thalis A. Kalfigopoulos | Date: | Sun, 12 May 2002 23:35:45 +0000 |
| Subject: | Re: Printing line "x" in a file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97266@lists.php.net to get a copy of this message | ||
If the file is relatively small, then the easiest would be to use file() which reads a file into an
array
$file_array=file($filename);
$text=$file_array[$line];
cheers,
thalis
On Sat, 11 May 2002, Andrew Conner wrote:
> I have a script where I need to get the text from line number "$line" in
> file "$filename" then save it to a var ($text) and then print it. For
> example, in the file lamb.txt (just an example file):
> "Mary was
> a little lamb, whose
> fleece
> was as
> white as snow."
> I need to get line number 3 ("fleece") and print it ("print $text").
> How would I go about this?
>
> Andrew Conner
> (All apologies if this messes up and does a multi-post)
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>