I have created two arrays and I want all the information from both to save to a .txt file. I want it to save in the format ('DATE' 'RAINFALL') inside the file. I tried many sources for help and I still can't get it to save. How can I do it? Thank you
The format inside the txt file
Code I currently have:
$rainf_array = array($rainf0, $rainf1, $rainf2, $rainf3, $rainf4, $rainf5, $rainf6 );
$date_array = array($date0, $date1, $date2, $date3, $date4, $date5, $date6 );
//Input value is saved to the file
{
$fileHandle = fopen($fileName, "w");
fwrite($fileHandle, $date_array .'' . $rainf_array . ",\n" );
fclose($fileHandle);
}

implodeor iterate over the array and concatenate to a string... or use a CSV parser, something like php.net/manual/en/function.fputcsv.php, that would be a CSV though although maybe you can change delimiter to a space (I would use some delimiter).'yyyy-mm-dd', '##'or'yyyy-mm-dd', ##.