note 33153 deleted from function.fgetcsv by felipe

From: Date: Sun, 10 Feb 2008 13:33:14 +0000
Subject: note 33153 deleted from function.fgetcsv by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135983@lists.php.net to get a copy of this message
Note Submitter: kyle at kghspam at yahoo.com ---- 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); ?>

« previous php.notes (#135983) next »