ID: 12643 Comment by: comic-erotic1754 at hotmail dot com Reported By: Grant dot Walters at walters dot co dot nz Status: Bogus Bug Type: Filesystem function related Operating System: Linux PHP Version: 4.0.6 New Comment:
<a href=http://an-classicpee-downl.da.ru>comic erotic</a> Previous Comments: ------------------------------------------------------------------------ [2002-06-18 17:49:03] Grant dot Walters at walters dot co dot nz So as my data that does not contain an "enclosure character", how should this be handled? The current manual page states that the parameter cannot be null. ------------------------------------------------------------------------ [2002-06-18 08:14:35] [EMAIL PROTECTED] you mixed up delimiter and enclosure arguments here and redefined only the delimiter from ',' to '~' you also have to redefine the enclosure character to something you don't use in your data instead of '"' to make your code work (4th parameter to fgetcsv()) ------------------------------------------------------------------------ [2002-06-18 06:34:01] [EMAIL PROTECTED] can you see if this is fixed in the latest non-stable cvs snapshot from snaps.php.net ? Derick ------------------------------------------------------------------------ [2001-08-08 10:51:27] [EMAIL PROTECTED] Reproduced with latest CVS of PHP. --Jani ------------------------------------------------------------------------ [2001-08-08 04:56:12] Grant dot Walters at walters dot co dot nz <? /* - fgetcsv when used with non " delimiter causes problems - script called from command line - on a large file (25,000 lines) the script will core dump most times with a segmentation fault Contents of gr DOS (CR/LF) or Unix (LF) record termination makes no difference to result ------------------------------------------ 26261~~5402211~yes~MASTERFULL~0 26263~~0126003045~yes~"PIONEERING"~0 26263~~039300358~yes~ " CASSIOPEIA~0 26263~~91054745~yes~OLYMPIC~0 26261~~2302~yes~MASTERLESS~0 26263~~6003045~yes~PIONEERING~0 ------------------------------------------ */ $file_name = "/tmp/unix/gr"; // Faulty: echo "\nFAULTY\n"; $text_file = fopen($file_name,"r"); if ($text_file) { $count=1; while ($data=fgetcsv($text_file,200,"~")) { echo "Record:$count:".$data[0].":".$data[2].":".$data[4]."\n"; $count++; } echo "$file_name Complete\n"; } fclose($text_file); /* Problem 1: This will stop in the third record because of the unmatched " Problem 2: It strips the " characters out of the resultant array fields */ //Working: echo "\nWORKING\n"; $text_file = fopen($file_name,"r"); if ($text_file) { $count=1; while ($data_in=fgets($text_file,200)) { $data=explode("~",$data_in); echo "Record:$count:".$data[0].":".$data[2].":".$data[4]."\n"; $count++; } echo "$file_name Complete\n"; } fclose($text_file); /* SCRIPT OUTPUT FAULTY Record:1:26261:5402211:MASTERFULL Record:2:26263:0126003045:PIONEERING /tmp/unix/gr Complete WORKING Record:1:26261:5402211:MASTERFULL Record:2:26263:0126003045:"PIONEERING" Record:3:26263:039300358: " CASSIOPEIA Record:4:26263:91054745:OLYMPIC Record:5:26261:2302:MASTERLESS Record:6:26263:6003045:PIONEERING /tmp/unix/gr Complete */ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=12643&edit=1
