note 97943 added to function.fgetcsv

From: Date: Mon, 17 May 2010 17:54:59 +0000
Subject: note 97943 added to function.fgetcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-169331@lists.php.net to get a copy of this message
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.) ---- Server IP: 62.237.7.3 Probable Submitter: 85.134.91.195 ---- Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php Edit -- https://master.php.net/note/edit/97943 Del: integrated -- https://master.php.net/note/delete/97943/integrated Del: useless -- https://master.php.net/note/delete/97943/useless Del: bad code -- https://master.php.net/note/delete/97943/bad+code Del: spam -- https://master.php.net/note/delete/97943/spam Del: non-english -- https://master.php.net/note/delete/97943/non-english Del: in docs -- https://master.php.net/note/delete/97943/in+docs Del: other reasons-- https://master.php.net/note/delete/97943 Reject -- https://master.php.net/note/reject/97943 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169331) next »