Skip to content

Instantly share code, notes, and snippets.

@leocavalcante
Last active December 14, 2015 12:59
Show Gist options
  • Save leocavalcante/5090588 to your computer and use it in GitHub Desktop.
Save leocavalcante/5090588 to your computer and use it in GitHub Desktop.
<?php
class DataLayer {
public $header;
public $data;
public function __construct ($header, $data) {
$this->header = $header;
$this->data = $data;
}
public function get ($key) {
return $this->data[array_search($key, $this->header)];
}
}
$header = array('name', 'phone', 'id');
$data = array('john', '11', '2');
$csv = new DataLayer($header, $data);
echo $csv->get('name');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment