note 105667 added to function.fgetcsv

From: Date: Tue, 06 Sep 2011 06:14:34 +0000
Subject: note 105667 added to function.fgetcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-182964@lists.php.net to get a copy of this message
It looks like this function has been improved since the note posted by "do not spam aleske at live dot ru" on 08-Jul-2010 01:38. In PHP 5.3.5, I find that it handles that complicated CSV example from Wikipedia perfectly, doubled-double-quotes, enclosed newlines, and all. test.csv: 1997,Ford,E350,"ac, abs, moon",3000.00 1999,Chevy,"Venture ""Extended Edition""","",4900.00 1999,Chevy,"Venture ""Extended Edition, Very Large""","",5000.00 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 test.php: <?php $f = fopen('test.csv','r'); while( $row = fgetcsv($f) ){ var_dump($row); } ?> Output: array(5) { [0]=> string(4) "1997" [1]=> string(4) "Ford" [2]=> string(4) "E350" [3]=> string(13) "ac, abs, moon" [4]=> string(7) "3000.00" } array(5) { [0]=> string(4) "1999" [1]=> string(5) "Chevy" [2]=> string(26) "Venture "Extended Edition"" [3]=> string(0) "" [4]=> string(7) "4900.00" } array(5) { [0]=> string(4) "1999" [1]=> string(5) "Chevy" [2]=> string(38) "Venture "Extended Edition, Very Large"" [3]=> string(0) "" [4]=> string(7) "5000.00" } array(5) { [0]=> string(4) "1996" [1]=> string(4) "Jeep" [2]=> string(14) "Grand Cherokee" [3]=> string(33) "MUST SELL! air, moon roof, loaded" [4]=> string(7) "4799.00" } ---- Server IP: 202.89.58.1 Probable Submitter: 202.78.240.7 ---- Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php Edit -- https://master.php.net/note/edit/105667 Del: integrated -- https://master.php.net/note/delete/105667/integrated Del: useless -- https://master.php.net/note/delete/105667/useless Del: bad code -- https://master.php.net/note/delete/105667/bad+code Del: spam -- https://master.php.net/note/delete/105667/spam Del: non-english -- https://master.php.net/note/delete/105667/non-english Del: in docs -- https://master.php.net/note/delete/105667/in+docs Del: other reasons-- https://master.php.net/note/delete/105667 Reject -- https://master.php.net/note/reject/105667 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182964) next »