The background:
One CSV file (data) with first line as header
One form passed to a form handler
The form is randomized but each element of the form needs to go into their proper columns.
$handle = fopen ("data/data.csv",'r');
$data = fgetcsv($handle, 1000, ",");
fclose($handle);
// write data in a csv file
$fp = fopen("data/data.csv", 'a+');
fwrite ($fp, "
$code,$now,$ipadress,$chronos,");
$param = count($_POST);
foreach ($_POST as $data => $v)
{
// $k = addslashes(trim($v));
fwrite ($fp, "$v,");
;
}
fclose($fp);
First I open the CSV file and get the first row and dump it into $data. My understanding was that the array is created automatically (and I made a test that $data[0] $data[1] ..etc were echoing what they were suppose to.).
Second I try to assign the $_POST the value that $data as a key is supposed to have ..
Well anyway .. nothing works like it supposed to 🙁
I just started in PHP .. thanks for your help !