note 93683 added to class.splfileobject

From: Date: Tue, 22 Sep 2009 20:48:35 +0000
Subject: note 93683 added to class.splfileobject
Groups: php.notes 
Request: Send a blank email to php-notes+get-160950@lists.php.net to get a copy of this message
splFileObject::SKIP_EMPTY seems to have no effect (v.5.3.0). <?php $file = './test.csv'; $txt = <<<TXT line,one line,three TXT; $file_obj = new SplFileObject($file, 'w+'); $file_obj->fwrite($txt); $file_obj->setFlags(splFileObject::READ_CSV | splFileObject::SKIP_EMPTY); foreach ($file_obj as $line) { echo $line[0] . ' ' . $line[1] . '<br />'; } echo '-------------<br />'; $file_obj->setFlags(splFileObject::SKIP_EMPTY); foreach ($file_obj as $line) { echo $line . '<br />'; } ?> Output: line one Notice: Undefined offset: 1 in {...}/test.php on line 13 line three ------------- line,one line,three ---- Server IP: 209.41.74.194 Probable Submitter: 173.21.113.105 ---- Manual Page -- http://www.php.net/manual/en/class.splfileobject.php Edit -- https://master.php.net/note/edit/93683 Del: integrated -- https://master.php.net/note/delete/93683/integrated Del: useless -- https://master.php.net/note/delete/93683/useless Del: bad code -- https://master.php.net/note/delete/93683/bad+code Del: spam -- https://master.php.net/note/delete/93683/spam Del: non-english -- https://master.php.net/note/delete/93683/non-english Del: in docs -- https://master.php.net/note/delete/93683/in+docs Del: other reasons-- https://master.php.net/note/delete/93683 Reject -- https://master.php.net/note/reject/93683 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160950) next »