RE: how to get row by row from CSV file

From: Date: Fri, 19 Apr 2002 08:11:23 +0000
Subject: RE: how to get row by row from CSV file
Groups: php.general 
Request: Send a blank email to php-general+get-93641@lists.php.net to get a copy of this message
Look at file() and fgets() functions. File gives you the whole file as a row per element array e.g. ... If ($csvfile = file("yourfile.csv")) { foreach($csvfile as $row) { $csvarray[] = explode(",", $row); } } ... gives you a structure from the csv that you can walk through in php. Using fopen and while fgets may be more efficient, especially if you don't want the whole file If ($fhandle = fopen("yourfile.csv", "r")) { while ($row = fgets($fhandle)) { ... // etc. } } Tim Ward Internet Chess www.chessish.com <http://www.chessish.com> ---------- From: Jack [SMTP:nedcor4@nedcor.com.hk] Sent: 18 April 2002 14:18 To: php-general@lists.php.net Subject: how to get row by row from CSV file Dear all I'm a beginner of php, i tried to get the CSV file, but it return like Column by Colume, but how i can get it in Row by Row, cause i want to point to specific data i want, but not the whole file content! -- Thx a lot! Jack nedcor4@nedcor.com.hk

« previous php.general (#93641) next »