Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 1
    You should show an example of the POST data. Note that you're opening the output file in write mode, so it will be completely overwritten. If you're loading the file into an array before overwriting it, you should show this code. Commented Aug 3 at 20:36
  • To ease diagnosing, could you 1. Try without a POST (just hardcoding the POSTed array at the start of your script), 2. try with another $responseFile (for example $fp = fopen($responseFile.'.new', 'w');, 3. try with all operations on $fp commented (fopen, fputcsv, fclose). Tell us if one of those works right. With a simple attempt to reproduce I get the loop as intended. Is $data a dumb PHP array (not an Iterator), with no reference used before the loop? Isn't there any other code playing with $data's internal pointer? Commented Aug 3 at 23:00
  • 1
    Thanks both for your suggestions, I'll add specific comments asap. @GuillaumeOutters, I've added an Edit to the post showing the entire php file and where $data comes from. Commented Aug 3 at 23:54
  • Not even testing, I'd say that the error lies in foreach ($data as &$row) (corresponding to my doubt about "no reference used before the loop"). Add an unset($row); after finishing the foreach ($data as &$row) loop. Commented Aug 4 at 0:08
  • @TUPKAP I've added an Edit to the post showing where the file is loaded into the array. The POST data is shown fully at the top of the data log, unless you want it shown differently? Commented Aug 4 at 0:09