Posted at

fgetcsv というものがあってだな

More than 5 years have passed since last update.


ltsv.php

<?php

$ret = array();

$file = new SplFileObject('hoge.ltsv');
$file->setFlags(SplFileObject::READ_CSV);
$file->setCsvControl("\t");

foreach ($file as $row) {
$keys = $values = array();

foreach ($row as $i) {
list($key, $value) = explode(':', $i, 2);

$keys[] = $key;
$values[] = $value;
}

$ret[] = array_combine($keys, $values);
}

var_dump($ret);