title: Used fgetcsv() for uploading CSV file but it show empty array
body: <p>I'm working on a <strong>codeIgniter3</strong> project where I need to upload CSV file into the database and I used custom made library for perform this task but it is not working and showing empty array!</p>
  <blockquote>
  <p>here are the library that I used &quot;<strong>Csvimport.php</strong>&quot;:</p>
  </blockquote>
  <pre><code>  &lt;?php defined('BASEPATH') or exit('No direct script access allowed');
  
    class Csvimport {
  
      var $fields;/** columns names retrieved after parsing */
      var $separator = ';';/** separator used to explode each line */
      var $enclosure = '&quot;';/** enclosure used to decorate each field */
      var $max_row_size = 120400;/** maximum row size to be used for decoding */
  
      function parse_file($p_Filepath) {
  
        $file = fopen($p_Filepath, 'r');
  
        $this-&gt;fields = fgetcsv($file, $this-&gt;max_row_size, $this-&gt;separator, $this-&gt;enclosure);
  
  
  
        $keys_values = explode(',', $this-&gt;fields[0]);
  
        $content = array();
        $keys = $this-&gt;escape_string($keys_values);
  
        $i = 1;
        while (($row = fgetcsv($file, 0, $this-&gt;separator, $this-&gt;enclosure)) != false) {
          
          if ($row != null) { // skip empty lines
            $values = explode(',', $row[0]);
            if (count($keys) == count($values)) {
              $arr = array();
              $new_values = array();
              $new_values = $this-&gt;escape_string($values);
              for ($j = 0; $j &lt; count($keys); $j++) {
                if ($keys[$j] != &quot;&quot;) {
                  $arr[$keys[$j]] = $new_values[$j];
                }
              }
  
              $content[$i] = $arr;
              $i++;
            }
          }
        }
        fclose($file);
        return $content;
      }
  
      function escape_string($data) {
        $result = array();
        foreach ($data as $row) {
          $result[] = str_replace('&quot;', '', $row);
        }
        return $result;
      }
  
    }
    ?&gt;
  </code></pre>
  <blockquote>
  <p>Here is the &quot;<strong>Controller</strong>&quot; code that I used to upload the CSV file:</p>
  </blockquote>
  <pre><code>$this-&gt;load-&gt;library('csvimport');
  $file_path = base_url().&quot;upload/test.csv&quot;;
  $csv_data = $this-&gt;csvimport-&gt;parse_file($file_path);
  echo '&lt;pre&gt;';
  print_r($csv_data);
  echo '&lt;/pre&gt;';
  </code></pre>
  <blockquote>
  <p>When I executed code it show empty array() as result!</p>
  </blockquote>
  <p>Please help me i'm stuck with this!! :(</p>
  <p>In CSV file I've following fields:</p>
  <pre><code>grade
  name
  address
  city
  phone
  email
  type
  created
  </code></pre>