note 54268 added to function.fgetcsv

From: Date: Wed, 29 Jun 2005 07:17:32 +0000
Subject: note 54268 added to function.fgetcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-91111@lists.php.net to get a copy of this message
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; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54268 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54268&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54268&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54268&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54268&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54268&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54268&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54268&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91111) next »