note 116688 added to function.str-getcsv

From: Date: Thu, 12 Feb 2015 10:58:32 +0000
Subject: note 116688 added to function.str-getcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-201699@lists.php.net to get a copy of this message
durik at 3ilab dot net brings up a good point but the solution provided may fail in certain (very rare) edge cases. I believe a more perfect solution is as follows: <?php // Use an I/O stream instead of an actual file. $handle = fopen('php://temp/myCSV', 'w+b'); // Write all the data to it fwrite($handle, $CSVString); // Rewind for reading rewind($handle); // use fgetcsv which tends to work better than str_getcsv in some cases $rows = array(); while ($row = fgetcsv($handle)) $rows[] = $row; ?> A variation on this technique can also be used to implement an 'str_putcsv' which PHP lacks. ---- Server IP: 72.52.91.14 Probable Submitter: 110.50.73.2 ---- Manual Page -- http://php.net/manual/en/function.str-getcsv.php Edit -- https://master.php.net/note/edit/116688 Del: integrated -- https://master.php.net/note/delete/116688/integrated Del: useless -- https://master.php.net/note/delete/116688/useless Del: bad code -- https://master.php.net/note/delete/116688/bad+code Del: spam -- https://master.php.net/note/delete/116688/spam Del: non-english -- https://master.php.net/note/delete/116688/non-english Del: in docs -- https://master.php.net/note/delete/116688/in+docs Del: other reasons-- https://master.php.net/note/delete/116688 Reject -- https://master.php.net/note/reject/116688 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201699) next »