title: How to write a single dimension array to a file in php a.k.a. file_put_contents vs fopen+fwrite
body: <p>Data: <code>$data = array('Alice', 'Bob', 'Carol', 'David', 'Elizabeth', 'Frank');</code></p>
  
  <hr>
  
  <p>Method A:</p>
  
  <blockquote>
    <p><code>file_put_contents('filename.ext', implode("\n", $data) );</code></p>
  </blockquote>
  
  <p>Method 2:</p>
  
  <pre>
  $fp = fopen('filename.ext', 'w');
  foreach($data as $name)
  {
    fwrite($fp, $name . "\n");
  }
  fclose($fp);
  </pre>
  
  <hr>
  
  <p>Does one method have any significant penalties over the other?</p>
  
  <p>Any significantly faster speed, even at a cost? at no cost?</p>
  
  <p>Preferences? Is it situational?
  Which would you use in production code vs 1-use throwaway scripts?</p>
  
  <p>Note: Please ignore any issues of checking to see if the filename is writable, or filepointer is !false. assume 0 friction, and everything just "works".</p>