phpでCSVを読み込むらしいライブラリ

古いディレクトリを漁っていると出てきたので一応サルベージ
もはや、いつどうして作ったのか不明なので、動作確認すらせずに公開だけしておくことにする

<?php  
  class CsvParser {  
    var $handle;  
    var $length;  
    var $d;  
    var $e;  
    var $fromEncode = "auto";  
    var $toEncode   = "auto";

    function CsvParser($handle, $length = null, $d = ',', $e = '"') {  
      $this->handle = $handle;  
      $this->length = $length;  
      $this->d      = preg_quote($d);  
      $this->e      = preg_quote($e);  
    }

    function getCSV() {

      $d      = $this->d;  
      $e      = $this->e;  
      $length = $this->length;  
      $handle = $this->handle;

      $_line  = "";  
      while ($eof != true) {  
        $_line .= (empty($length) ? fgets($handle) : fgets($handle, $length));  
        $itemcnt = preg_match_all('/' . $e . '/', $_line, $dummy);  
        if ($itemcnt % 2 == 0) {  
          $eof = true;  
        }  
      }

      $_line = mb_convert_encoding($_line, $this->toEncode, $this->fromEncode);

      $_csv_line = preg_replace('/(?:\\r\\n|[\\r\\n])?$/', $d, trim($_line));  
      $_csv_pattern = '/(' . $e . '[^' . $e . ']*(?:' . $e . $e . '[^' . $e . ']*)*' . $e . '|[^' . $d . ']*)' . $d . '/';  
      preg_match_all($_csv_pattern, $_csv_line, $_csv_matches);  
      $_csv_data = $_csv_matches[1];  
      for ($_csv_i = 0; $_csv_i < count($_csv_data); $_csv_i++) {  
        $_csv_data[$_csv_i] = preg_replace('/^' . $e . '(.*)' . $e . '$/s', '', $_csv_data[$_csv_i]);  
        $_csv_data[$_csv_i] = str_replace($e . $e, $e, $_csv_data[$_csv_i]);  
      }  
      return empty($_line) ? false : $_csv_data;  
    }

  }  
?>