Re: splitting up a file that has two columns
| From: | Daniel Convissor | Date: | Thu, 13 Jul 2000 13:17:33 +0000 |
| Subject: | Re: splitting up a file that has two columns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6432@lists.php.net to get a copy of this message | ||
Hi David:
david.tansley@acelondon.co.uk wrote:
>
> I have the following file;
> item1:345
> item2:12344
>
> I need to read in the file and be able to assign the first column to a var
> and the second column to a var from a loop.
Use the fgetscsv() function. For example:
$TaxFile = fopen("./tax.txt", "r");
while ( $TaxArray = fgetcsv($TaxFile, 14) ) {
... blah blah blah ....
}
In your case, you'll need to add the optional string delimeter parameter
because you yave the file split on ":" rather than the default "," So,
you'd
call
fgetcsv($TaxFile, 14, ":")
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
More than just answers. Solutions. (SM)
http://www.analysisandsolutions.com/
4015 7 Av #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409