note 97630 added to function.fgetcsv

From: Date: Thu, 29 Apr 2010 11:54:06 +0000
Subject: note 97630 added to function.fgetcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-168780@lists.php.net to get a copy of this message
If you want to load some translations for your application, don't use csv files for that, even if it's easier to handle. The following code snippet: <?php $lang = array(); $handle = fopen('en.csv', 'r'); while($row = fgetcsv($handle, 500, ';')) { $lang[$row[0]] = $row[1]; } fclose($handle); ?> is about 400% slower than this code: <?php $lang = array(); $values = parse_ini_file('de.ini'); foreach($values as $key => $val) { $lang[$key] = $val; } ?> That's the reason why you should allways use .ini files for translations... http://ch2.php.net/manual/en/function.parse-ini-file.php ---- Server IP: 69.147.83.197 Probable Submitter: 217.162.145.246 ---- Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php Edit -- https://master.php.net/note/edit/97630 Del: integrated -- https://master.php.net/note/delete/97630/integrated Del: useless -- https://master.php.net/note/delete/97630/useless Del: bad code -- https://master.php.net/note/delete/97630/bad+code Del: spam -- https://master.php.net/note/delete/97630/spam Del: non-english -- https://master.php.net/note/delete/97630/non-english Del: in docs -- https://master.php.net/note/delete/97630/in+docs Del: other reasons-- https://master.php.net/note/delete/97630 Reject -- https://master.php.net/note/reject/97630 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168780) next »