Re: Reading from a file

From: Date: Tue, 01 Jul 2003 16:12:45 +0000
Subject: Re: Reading from a file
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-29001@lists.php.net to get a copy of this message
$data = file('c:\file.txt'); for($counter = 0; $counter < count($data); $counter++) $data[$counter] = explode("\t",$data[$counter]); Poof. For: bob nina jim joe You will get: $data[0][0] = 'bob'; $data[0][1] = 'nina'; $data[0][2] = 'jim'; $data[0][3] = 'joe'; Nice and easy to recurse through. On Tue, 2003-07-01 at 12:10, Rick Dahl wrote: > I need to read from a file that is tab delimited. Is there anyway to specify that it reads > between each tab and that is it. I know fread() uses bytes to figure out what to read but that > isn't very practical in my case. > > Also, how do I get rid of any white space at the end of a variable if there is some once it is > read in? > > - Rick -- Adam Voigt (adam@cryptocomm.com) Linux/Unix Network Administrator The Cryptocomm Group

« previous php.db (#29001) next »