note 97943 deleted from function.fgetcsv by danbrown

From: Date: Tue, 18 May 2010 15:21:01 +0000
Subject: note 97943 deleted from function.fgetcsv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169371@lists.php.net to get a copy of this message
Note Submitter: simon at iki dot fi ---- Made this slight mod of the Example #1 above. It's a simple way to pick out certain cell data, eg. if you want to display data from specific cells in certain places. <?php $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++; $c[]=$data; // $c = cell data } fclose($handle); } ?> Then in the template you can insert data from certain cells like this: <?php print $c[1][2]; ?> The first value 1 would be row 2 (since counting starts from 0) and the second value 2 would represent column C (the third column). (Or if your php-configuration allows you might want to use <?= $c[1][2]; ?> instead.)

« previous php.notes (#169371) next »