RE: [PHP] getting one line from file
| From: | Chris Murley | Date: | Thu, 31 Aug 2000 13:15:16 +0000 |
| Subject: | RE: [PHP] getting one line from file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14584@lists.php.net to get a copy of this message | ||
how big is the file your reading?
How beefy is your webserver?
Is this file one line? if so why grep? thats overhead you dont need?
just open the file, and put the whole thing into any array, then access
what you need. It will probally be quicker then doing a system call, and
using grep tooo, , all that causes overhead. on the other hand if this
file is a big one, that will wlos you down to.
On Thu, 31 Aug 2000, Michael Packer wrote:
>
> > pac@stingrayboats.com ("Michael Packer") writes:
> >
> >> I'm just learning PHP and have a question....in perl I used to do this:
> >>
> >> $info =
grep "676" /tmp/somefile.txt;
> >> (i know there was only one line in the file with that number,
> >>thats why it's not @info)
> >>
> >> i need to only get one line out of this file that is very large
> >>(which is why i don't want to open it read through the file until i find
> >>the correct line)...
> >
> > try this: :-)
> >
> > $info = grep "676" /tmp/somefile.txt;
>
>
> well i tried this..it works, but damn it take a performance hit...do system
> calls rereally effect PHP that much?
>
> instead of instantly loading, it now takes about 2-3 seconds
>
> any other ideas?
>
> thanks!
> pac
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>