Skip to content

Instantly share code, notes, and snippets.

@jbnv
Created February 15, 2017 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbnv/b93b2c69b85a9346a8638bd9f518a5b3 to your computer and use it in GitHub Desktop.
Save jbnv/b93b2c69b85a9346a8638bd9f518a5b3 to your computer and use it in GitHub Desktop.
Convert various list formats to arrays.
$csv = <<<CONTENT
...
CONTENT;
$outbound = array();
foreach(explode("\n",$tsv) AS $line) {
$a = explode(",",$line);
$outbound[$a[0]] = $a[1];
}
$tsv = <<<TSV
...
TSV;
$outbound = array();
foreach(explode("\n",$tsv) AS $line) {
$a = explode("\t",$line);
$outbound[$a[0]] = $a[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment