note 98502 deleted from function.fgetcsv by cmb

From: Date: Sun, 16 Jun 2019 08:09:31 +0000
Subject: note 98502 deleted from function.fgetcsv by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211267@lists.php.net to get a copy of this message
Note Submitter: carloshNOSPAM at 4sconsult dot com ---- For my surprise this function using 5.3.2 on windows now when it reads an empty line it returns FALSE instead of an empty array as the previous versions. This affect code that do not check the result and tries something like this: <?php while(!feof($fp)){ $line=fgetcsv($fp,4096,',','"'); foreach($line as $key=>$value){ // .... } } ?> when it was empty array this foreach pass ok but now with FALSE gives this error: Invalid argument supplied for foreach() Anyways, it is good idea to check what you getting before process further. This following line will fix the existing code. if(!$line=fgetcsv($fp,4096,',','"') continue;

« previous php.notes (#211267) next »