$value) * * @var array */ protected $currentData; public function __construct($filename, $fields) { $this->fields = $fields; $f = new File($filename); $f->setFlags( File::DROP_NEW_LINE | File::READ_AHEAD | File::SKIP_EMPTY ); parent::__construct($f); } /** * Return the current data * * @return array */ public function current() { return $this->currentData; } /** * Accept lines matching the given PCRE pattern * * @return bool * * @throws FileReaderException If PHP failed parsing the PCRE pattern */ public function accept() { $data = array(); $matched = preg_match( $this->fields, $this->getInnerIterator()->current(), $data ); if ($matched === false) { throw new FileReaderException('Failed parsing regular expression!'); } else if ($matched === 1) { foreach ($data as $key => $value) { if (is_int($key)) { unset($data[$key]); } } $this->currentData = $data; return true; } return false; } }