$records = array(
array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe',
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith',
),
array(
'id' => 5342,
'first_name' => 'Jane',
'last_name' => 'Jones',
),
array(
'id' => 5623,
'first_name' => 'Peter',
'last_name' => 'Doe',
)
);
$result = [];
$file = file_get_contents('file.txt');
$rows = explode('\n', $file);
$titles = explode('\t', array_shift($rows));
foreach ($rows as $row) {
$cols = explode('\t', $row);
for ($i=0; $i<count($titles); $i++) {
if (isset($cols[$i])) {
$cols[$titles[$i]] = $cols[$i];
unset($cols[$i]);
}
}
$result[] = $cols;
}
$first_names = array_column($result, 'first_name');
print_r($first_names);