title: Add each line of CSV file into an array using PHP
body: <p>I am almost embarrassed to ask this, but I've been trying to accomplish this task for a few hours now. Without a thorough grasp of the <a href="http://php.net/manual/en/function.fopen.php" rel="nofollow">fopen</a> or <a href="http://php.net/manual/en/function.fgetcsv.php" rel="nofollow">fgetcsv</a>  functions, I'm a bit lost. Each example I find does not quite work for me.</p>
  
  <p>I'm seeking a way to load each line of a CSV file into one array. For example, if this is my CSV file:</p>
  
  <pre><code>Apple,Banana,Orange
  Kiwi,Watermelon,Pineapple
  Dog,Cat,Bird
  </code></pre>
  
  <p>Then this would be my array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Apple,Banana,Orange
      [1] =&gt; Kiwi,Watermelon,Pineapple
      [2] =&gt; Dog,Cat,Bird
  )
  </code></pre>
  
  <p>I'd appreciate any tips. Thanks! :)</p>
  
  <hr>
  
  <p>Just for reference, this is what I have so far:</p>
  
  <pre><code>$list = '../reports/apples.csv';
  
  $csvfile = fopen($list,'rb');
  while(!feof($csvfile)) {
  $listofthings[] = fgetcsv($csvfile);
  }
  fclose($csvfile);
  
  print_r($listofthings);
  </code></pre>
  
  <p>However, this is producing a multidimensional array as follows, when I'd rather just have one big array.</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; Apple
              [1] =&gt; Banana
              [2] =&gt; Orange
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; Kiwi
              [1] =&gt; Watermelon
              [2] =&gt; Pineapple
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; Dog
              [1] =&gt; Cat
              [2] =&gt; Bird
          )
  )
  </code></pre>