note 72156 deleted from function.fgetcsv by cmb

From: Date: Sun, 16 Jun 2019 08:08:33 +0000
Subject: note 72156 deleted from function.fgetcsv by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211265@lists.php.net to get a copy of this message
Note Submitter: Mr N. ---- There is still a bug with column headings ( "false" != false ) <?php function parse_csv_file($file, $columnheadings = false, $delimiter = ',', $enclosure = "\"") { $row = 1; $rows = array(); $handle = fopen($file, 'r'); while (($data = fgetcsv($handle, 1000, $delimiter, $enclosure )) !== FALSE) { if (!($columnheadings == false) && ($row == 1)) { $headingTexts = $data; } elseif (!($columnheadings == false)) { 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 (#211265) next »