Skip to content

Instantly share code, notes, and snippets.

@objectivehtml
Created February 1, 2013 20:02
Show Gist options
  • Select an option

  • Save objectivehtml/4693712 to your computer and use it in GitHub Desktop.

Select an option

Save objectivehtml/4693712 to your computer and use it in GitHub Desktop.
/**
* csv parser
*
* reads csv data and transforms it into php-data
*
* @access protected
* @return boolean
*/
protected function parse()
{
if (!$this->validates()) {
return false;
}
$c = 0;
$d = $this->settings['delimiter'];
$e = $this->settings['escape'];
$l = $this->settings['length'];
$res = fopen($this->_filename, 'r');
while ($keys = fgetcsv($res, $l, $d, $e)) {
if ($c == 0) {
$this->headers = $keys;
} else {
array_push($this->rows, $keys);
}
$c ++;
}
fclose($res);
$this->removeEmpty();
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment