public function parse(FileInterface $file, ParseOptions $options) { $done = false; $this->field_separator = $options->getFieldSeperator(); $this->text_delimiter = $options->getDeliminator(); $this->eol_ignorecr = $options->getEolIgnoreChr(); $header = NULL; $skip_rows = $options->getSkipRows(); //skip the number of linex while ($skip_rows--) { $this->read($file); } //fetch the header row if ($options->getHasHeaderRow() === TRUE) { $header = $this->read($file); // send the record to the event $this->event_class->dispatch('header_parsed', new HeaderParsed($header, 0)); } $row = 0; while (!$file->feof()) { if (($record = $this->read($file)) !== FALSE) { $user_record = array(); $record_pointer = 0; if ($header !== NULL) { foreach ($header as $v) { $user_record[$v] = $record[$record_pointer]; $record_pointer++; } } else { foreach ($record as $v) { $user_record["FIELD" . ($record_pointer + 1)] = $record[$record_pointer]; $record_pointer++; } } ++$row; // send the record to the event $this->event_class->dispatch('row_parsed', new RowParsed($user_record, $row)); } } $file->fclose(); return true; }