note 120296 added to function.fputcsv
| From: | toni | Date: | Thu, 08 Dec 2016 05:43:21 +0000 |
| Subject: | note 120296 added to function.fputcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208274@lists.php.net to get a copy of this message | ||
I have a small code,how to read and insert Informations in a CSV File with "fputcsv" and
"fgetcsv":
<?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,500,";"))
{
echo"<p>
Row1: ".$row[0]."<br>
Row2: ".$row[1]."<br
Row3: ".$row[2]."<br></p>";
}
fclose($pointer);
}
else
{
echo"<p> It was not possible to open the File!</p>";
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 108.171.129.164 (proxied: 166.49.145.214)
----
Manual Page -- http://php.net/manual/en/function.fputcsv.php
Edit -- https://master.php.net/note/edit/120296
Del: integrated -- https://master.php.net/note/delete/120296/integrated
Del: useless -- https://master.php.net/note/delete/120296/useless
Del: bad code -- https://master.php.net/note/delete/120296/bad+code
Del: spam -- https://master.php.net/note/delete/120296/spam
Del: non-english -- https://master.php.net/note/delete/120296/non-english
Del: in docs -- https://master.php.net/note/delete/120296/in+docs
Del: other reasons-- https://master.php.net/note/delete/120296
Reject -- https://master.php.net/note/reject/120296
Search -- https://master.php.net/manage/user-notes.php