note 54268 deleted from function.fgetcsv by danbrown

From: Date: Sun, 17 May 2009 18:17:10 +0000
Subject: note 54268 deleted from function.fgetcsv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155093@lists.php.net to get a copy of this message
Note Submitter: essaym.net ---- Heres a function i wrote because all the other functions on here didnt work quiet as easy as I wanted them to: It opens the CSV file, and reads it into a 3d array. If you set $columnsOnly, you will only get the first line. <?php function CSV2Array($openFile, $columnsOnly = false) { $handle = fopen ($openFile,"r"); $rows = 0; while (!feof($handle)) { $columns[] = explode(",", fgets($handle, 4096)); if ($rows++ == 0 && $columnsOnly) break; } fclose ($handle); return $columns; } ?>

« previous php.notes (#155093) next »