note 70333 deleted from function.fgetcsv by felipe

From: Date: Sun, 09 Dec 2007 15:48:32 +0000
Subject: note 70333 deleted from function.fgetcsv by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133032@lists.php.net to get a copy of this message
Note Submitter: LEON _AT_ TIM-ONLINE _DOT_ NL ---- I wrote this function for myself. I think it's handy: function parse_csv_file($file, $columnheadings = false, $delimiter = ',', $enclosure = null) { $row = 1; $rows = array(); $handle = fopen($file, 'r'); while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) { if ($columnheadings == true && $row == 1) { $headingTexts = $data; } elseif ($columnheadings == true) { var_dump($data); foreach ($data as $key => $value) { unset($data[$key]); $data[$headingTexts[$key]] = $value; } } else { $rows[] = $data; } $row++; } fclose($handle); return $rows; }

« previous php.notes (#133032) next »