Re: File read question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: $column<br>\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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux