function get_second_words() {
$firstWords = array();
$file = file("data.txt");
foreach ($file as $line) {
if (trim($line) != '') {
$expl = explode(" ", $line);
$firstWords[] = $expl[1];
}
}
return $firstWords;
}
echo implode(', ', get_second_words());
/*
run:
is, is, was, Lerdorf, reference
*/