[PHP-DB] Reading from a file

2003-07-01 Thread Rick Dahl
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


Re: [PHP-DB] Reading from a file

2003-07-01 Thread Adam Voigt
$data = file('c:\file.txt');

for($counter = 0; $counter  count($data); $counter++)
$data[$counter] = explode(\t,$data[$counter]);

Poof. For:

bob ninajim 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 ([EMAIL PROTECTED])
Linux/Unix Network Administrator
The Cryptocomm Group


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Reading from a file

2003-07-01 Thread Gary . Every
Looks like the first question was answered correctly, for the second one
look at the ltrim and rtrim functions.
$var = ;
$var = rtrim($var);
echo :$var:;
output is
::


Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


 -Original Message-
 From: Rick Dahl [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, July 01, 2003 11:11 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Reading from a file
 
 
 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