Re: Question: Processing files in directory and parsing...

From: Date: Sun, 08 Jul 2001 01:47:13 +0000
Subject: Re: Question: Processing files in directory and parsing...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56707@lists.php.net to get a copy of this message
on 7/7/01 7:38 PM, mike cullerton at michaelc@cullerton.com wrote: > on 7/7/01 7:02 PM, Jeff Lewis at jeff@hyrum.net wrote: > >> So I need to know how to process the files in the directory and then how to >> process a few lines. The structure will always be the same and having the >> columns starting at the same position each time. > > first, do the files have all the heading info in them as well, or just the > data? ie, are all the lines the same, or are there some that include stuff > other than data? > > if the files cantaon only data, once you get a file in hand, this can parse > the lines. > > $fd = fopen ($file,'r'); oops, missed something... while (!feof ($fd)) { > $buffer = fgets($fd, 4096); > $field1 = substr($buffer,0,x); > $field2 = substr($buffer,x,y); > $field3 = substr($buffer,x+y,z); > ... > > where x is the length of the first field, y length of the second ... > > also, you may want to trim() the fields. > > i'm sure others around here can come up with something better. > > :) > > -- mike cullerton > -- mike cullerton

« previous php.general (#56707) next »