title: CSV Export reaches 500 lines then stops
body: <p>I have an export function that converts data posted from a form into a CSV file. The issue is when the number of rows exceeds 500 it stops the CSV.</p>
  
  <p>My php.ini file shows that my <code>upload_max_filesize</code> and <code>post_max_size</code> equates to 0. So it should be unlimited, so my assumption is that it's not form size that's the issue.</p>
  
  <p>My current code looks like this:</p>
  
  <pre><code>$data = $_POST['ids'];
  
  $ebayMmlSql = 'SELECT `UKM_Make`, `UKM_Model`, `UKM_CCM`, `UKM_Submodel`, `Year`, `UKM_StreetName`
                 FROM `ebay_mml`
                 WHERE `ePID` = :epid';
  
  $aiSql = 'INSERT INTO `model_epid_matches` (`epid`, `model_id`) VALUES (:epid, :model);';
  
  $rows = array();
  
  $i = 0;
  
  foreach ($data as $key =&gt; $ids)
  {
      foreach ($ids as $id)
      {
          if (isset($id['epid']) &amp;&amp; $id['epid'] !== '') {
              # run select
              $ebayMmlQry = $handler-&gt;prepare($ebayMmlSql);
              $ebayMmlQry-&gt;execute(array(':epid' =&gt; $id['epid']));
  
              # if insert is true, run insert
              if (isset($_POST['insert']) &amp;&amp; $_POST['insert'] == true) {
                  if (isset($id['new']) &amp;&amp; $id['new'] == true) {
                      $aiQry = $handler-&gt;prepare($aiSql);
                      $aiQry-&gt;execute(array(':epid' =&gt; $id['epid'], ':model' =&gt; $id['mod_id']));
                  }
              }
  
              $rows[$key][$i]['action'] = ($i == 0 ? 'Revise' : '');
              $rows[$key][$i]['item_id'] = ($i == 0 ? 'Insert ItemID for '. $key : '');
              $rows[$key][$i]['relationship'] = ($i == 0 ? '' : 'Compatibility');
              $rows[$key][$i]['relationship_details'] = '';
  
              foreach ($ebayMmlQry-&gt;fetchAll(PDO::FETCH_ASSOC) as $k =&gt; $value)
              {
                  $rows[$key][$i]['relationship_details'] = 'UKM_Make='. $value['UKM_Make'] .'|';
                  $rows[$key][$i]['relationship_details'] .= 'UKM_Model='. $value['UKM_Model'] .'|';
                  $rows[$key][$i]['relationship_details'] .= 'UKM_CCM='. $value['UKM_CCM'] .'|';
                  $rows[$key][$i]['relationship_details'] .= 'UKM_Submodel='. $value['UKM_Submodel'] .'|';
                  $rows[$key][$i]['relationship_details'] .= 'Year='. $value['Year'] .'|';
                  $rows[$key][$i]['relationship_details'] .= 'UKM_StreetName='. $value['UKM_StreetName'];
              }
  
              $i++;
          }
      }
  
      $i = 0;
  }
  
  
  # testing count of rows before gen_csv_file on screen
  # $total = 0;
  
  # foreach ($rows as $key =&gt; $row)
  # {
  #    echo '&lt;pre&gt;';
  #    var_dump($key. ': ' .count($row));
  #    echo '&lt;/pre&gt;';
  
  #    $total += count($row);
  # }
  
  # var_dump($total);
  
  gen_csv_file($rows, 'ebay.csv');
  
  function gen_csv_file($data, $file)
  {
      header('Content-Type: text/csv');
      header('Content-Disposition: attachment; filename='. $file);
      header('Pragma: no-cache');
      header('Expires: 0');
  
      $output = fopen('php://output', 'w');
  
      fputcsv(
          $output,
          array(
              'Action(SiteID=UK|Country=GB|Currency=GBP|Version=941)',
              'ItemID',
              'Relationship',
              'RelationshipDetails'
          )
      );
  
      foreach ($data as $key =&gt; $row)
      {
          foreach ($row as $item)
          {
              fputcsv($output, $item);
          }
      }
  
      fclose($output);
  }
  </code></pre>
  
  <p>I can't seem to get to the root of the issue - maybe memory issue?</p>
  
  <h1>update</h1>
  
  <p>@AymDev linked this question: <a href="https://stackoverflow.com/questions/16470527/warning-input-variables-exceeded-1000">Warning: Input variables exceeded 1000</a></p>
  
  <p>Was a good read, however:</p>
  
  <p>1) The highest voted answer led me to var_dump the count of $_POST which returned 1 (though that doesn't exceed 1000 so not sure why it doesn't work?)</p>
  
  <p>2) The accepted answer suggests setting <code>Content-Type</code> in the header which I've already done</p>
  
  <p>I could always set the <code>max_input_vars</code> via <code>ini_set</code>/.htaccess to avoid changing on server ...</p>
  
  <p>Thanks,</p>