Skip to content

Instantly share code, notes, and snippets.

@amitayh
Created July 29, 2013 11:59
Show Gist options
  • Save amitayh/6103850 to your computer and use it in GitHub Desktop.
Save amitayh/6103850 to your computer and use it in GitHub Desktop.
<?php
$filename = 'data.txt';
$delimiter = "\t";
$file = new SplFileObject($filename, 'r');
$file->setFlags(SplFileObject::READ_CSV);
$file->setCsvControl($delimiter);
$data = array();
foreach ($file as $row) {
list($key, $value) = $row;
$data[$key] = $value;
}
print_r($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment