This tutorial show's how to create a new CSV file through PHP script.
This script is more helpful for php developer to create a new CSV file in array formate.
function functionname (parameter)
{
if (($handle = fopen("$data", "r")) !== FALSE)
{
while (($csv_data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$categorydata[]=$csv_data;
}
}
$categorynum=count($categorydata);
$categorydata[$categorynum][1]=$new_cat_name;
$categorydata[$categorynum][2]='1';
$categorydata[$categorynum][3]='n';
$categorydata[$categorynum][4]='0';
$categorydata[$categorynum][5]=$overcategory;
$filepointer = fopen($data, 'w') or error('ggg');
foreach($categorydata as $updated_data)
{
fputcsv($filepointer,$updated_data);
}
fclose($filepointer);
}
0 Comment(s)