note 70774 deleted from function.fgetcsv by felipe

From: Date: Sun, 09 Dec 2007 15:48:52 +0000
Subject: note 70774 deleted from function.fgetcsv by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133033@lists.php.net to get a copy of this message
Note Submitter: php [at] barryhunter co uk ---- Re: LEON _AT_ TIM-ONLINE _DOT_ NL 12-Oct-2006 09:47 Very Handy Function, thanks! However I needed to tweak it a bit: (remove the var_dump, store the info in the big array when using columnheadings and forward $enclosure to the fgetcsv) <?php function parse_csv_file($file, $columnheadings = false, $delimiter = ',', $enclosure = null) { $row = 1; $rows = array(); $handle = fopen($file, 'r'); while (($data = fgetcsv($handle, 1000, $delimiter, $enclosure )) !== FALSE) { if ($columnheadings == true && $row == 1) { $headingTexts = $data; } elseif ($columnheadings == true) { foreach ($data as $key => $value) { unset($data[$key]); $data[$headingTexts[$key]] = $value; } $rows[] = $data; } else { $rows[] = $data; } $row++; } fclose($handle); return $rows; } ?>

« previous php.notes (#133033) next »