----- Original Message ----- 
From: "Justin French">
> The disadvantage is that you have to loop through the data twice (once
> as a tab-delimited file, once as an assoc. array), which would have
> obvious problems when there's a large set of data that needs to be
> looped through often.

> Justin French

Justin,
Your fgetcsv() function was what I was needing. I found this in it notes:

<snip_from_fgetcsv>
 Quick and dirty script to take a csv file and turn it into a
multidimensional associative array structure using the first line of the csv
as the hash key names.

<?
$i = 0;
$handle = fopen ("file.csv","r");
while($data = fgetcsv ($handle, 1000, ",")) {
if ($i == 0) { $key_arr = $data; }
reset($key_arr);
while(list($index,$name) = each($key_arr)) { $temp_arr[$name] =
$data[$index]; }
$result_arr[$i] = $temp_arr;
$i++;
}
fclose ($handle);
?>
</snip_from_fgetcsv>


Thanks!
-eric wood

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

Reply via email to