note 120291 deleted from function.fgetcsv by cmb
| From: | cmb@php.net | Date: | Wed, 07 Dec 2016 15:55:41 +0000 |
| Subject: | note 120291 deleted from function.fgetcsv by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208262@lists.php.net to get a copy of this message | ||
Note Submitter: bobo
----
How to read and insert Informations in a CSV File
<?php
//Insert Informations
$listwithinput=array(
array("First","Second","Third",""),
array("A","B","C",""),
array("1","2","3","")
);
$pointer=fopen("list.csv","a+");
if($pointer!=false)
{
foreach($listwithinput as $value)
{
fputcsv($pointer,$value,";");
}
fclose($pointer);
}
else
{
echo"<p> It was not possible to open the File!</p>";
}
//Read Informations
$pointer=fopen("list.csv","a+");
if($pointer!=false)
{
while($row=fgetcsv($pointer,600,";"))
{
echo"<p>
column1: ".$row[0]."<br>
column2: ".$row[1]."<br>
column3: ".$row[2]."<br></p>";
}
fclose($pointer);
}
else
{
echo"<p> It was not possible to open the File!</p>";
}
?>