Re: [PHP-DB] File read question

2005-07-22 Thread Micah Stevens

What's the file format, if things are delimited, just read the first line out 
from the file, after getting it with file() or something, and then use 
explode() to break it up into an array based on the delimeter.

Then you can foreach through it. 

Assuming it's comma seperated, this would work I think:

$file = file(filename.csv);
$columns = explode(,, $file[0]);
echo count($columns). total columns.br\n;
foreach($columns as $column) {
echo Column: $columnbr\n;
}


Is that what you mean? 

-Micah

On Friday 22 July 2005 5:59 pm, Chris Payne wrote:
 Hi there everyone,



 I'm having to make an editor with PHP and MySQL for assigning column values
 that change (Long story), basically I can open the file and read it no
 problem, but how can I open a file and only display the first row of
 information with all columns?  The column count changes every week which is
 what makes it more tricky for me.



 I use the fopen command to read the file and that's not an issue, I'm just
 not sure how to read the first row with all columns, any help would REALLY
 be appreciated.



 Regards



 Chris Payne

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



RE: [PHP-DB] File read question

2005-07-22 Thread Chris Payne
Hi there,

That actually looks like it might do it, thank you.  I'm having a slow brain
day today :0)

Chris

What's the file format, if things are delimited, just read the first line
out 
from the file, after getting it with file() or something, and then use 
explode() to break it up into an array based on the delimeter.

Then you can foreach through it. 

Assuming it's comma seperated, this would work I think:

$file = file(filename.csv);
$columns = explode(,, $file[0]);
echo count($columns). total columns.br\n;
foreach($columns as $column) {
echo Column: $columnbr\n;
}


Is that what you mean? 

-Micah

On Friday 22 July 2005 5:59 pm, Chris Payne wrote:
 Hi there everyone,



 I'm having to make an editor with PHP and MySQL for assigning column
values
 that change (Long story), basically I can open the file and read it no
 problem, but how can I open a file and only display the first row of
 information with all columns?  The column count changes every week which
is
 what makes it more tricky for me.



 I use the fopen command to read the file and that's not an issue, I'm just
 not sure how to read the first row with all columns, any help would REALLY
 be appreciated.



 Regards



 Chris Payne

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

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